Tiny Core Linux

General TC => Programming & Scripting - Unofficial => Topic started by: JoXo009 on November 13, 2009, 03:30:42 PM

Title: rotating 'progress' dash in aterm
Post by: JoXo009 on November 13, 2009, 03:30:42 PM
Once saw code creating a rotating dash in aterm as signal of work in progress.

It was a loop exchanging -,\,|and / sign paused by sleep 1 each.

I need such solution, but couldn't find the old code and created some solution with
echo -ne "^[[1;D" for backspace and
echo -ne "^[[1;A" for cursor up

The backspace solution results in a rotating dash with ugly blinking cursor aside.

(http://i36.tinypic.com/23j3luo.png)

As shown obove, the cursor up solution places the cursor away, at the beginning of the line, but always needs to retype the whole line with the rotating dash at its end.

See sample code attached.

I think there might be better solutions. Any hint?

_____________
to download sample code you need to log in
Title: Re: rotating 'progress' dash in aterm
Post by: Kingdomcome on November 13, 2009, 03:47:57 PM
The code for the rotating dash in TC is located in /etc/init.d/tc-functions at line 55. You can easily take advantage of that code by sourcing tc-functions in your script. My experience is that the command which you want the rotating dash to be displayed for needs to be backgrounded for things to work right.
An example using the sleep command to have the dash rotate for 10 seconds:
Code: [Select]
#!/bin/sh
. /etc/init.d/tc-functions

sleep 10 &
rotdash $!
Title: Re: rotating 'progress' dash in aterm
Post by: ^thehatsrule^ on November 17, 2009, 04:55:21 PM
Just a side note: FYI, these are not aterm specific ;)