BashScripts.org
http://bashscripts.org/forum/

Spinners and other fun stuff.
http://bashscripts.org/forum/viewtopic.php?f=7&t=177
Page 1 of 1

Author:  crudball [ Sat Apr 08, 2006 1:41 am ]
Post subject:  Spinners and other fun stuff.

Here is a use I though of for it....
Code:
#!/bin/bash
search ()
{
        delay1='sleep .08'
   wipescreen='echo -ne \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b'
echo -ne "|                                                          ";$delay1;$wipescreen
echo -ne "/                                                            ";$delay1;$wipescreen
echo -ne "-                                                          ";$delay1;$wipescreen
echo -ne "\                                                          ";$delay1;$wipescreen
echo -ne "|                                                        ";$delay1;$wipescreen
echo -ne "/                                                       ";$delay1;$wipescreen
echo -ne "-                                                       ";$delay1;$wipescreen
echo -ne "\                                                    ";$delay1;$wipescreen
echo -ne "|                                                   ";$delay1;$wipescreen
echo -ne "";$delay1;$wipescreen
}
echo "Please wait while the computer searches for the file... "
search
locate $1

It the little spinny thing you see on most linux installers...
Ok, I have though of a use for this little function but can anyone tell me if you can use if to see if a certain script or file is running...

[mod] Split from other topic as it had started to stray from the original post[/mod]

Author:  crouse [ Sat Apr 08, 2006 10:30 am ]
Post subject: 

Code:
#!/bin/bash
spin ()
{
BLUE='\e[0;34m'
RED='\e[0;31m'
WHITE='\e[1;37m'
NC='\e[0m'

echo -ne "${RED}-"
echo -ne "${WHITE}\b|"   
echo -ne "${BLUE}\bx"
sleep .02
echo -ne "${RED}\b+${NC}"
}

for i in `seq 1 15` ; do spin; done
exit


Try that for a spinner instead crudball.... ;) You can change the duration of spin, and length of spin pretty easily this way. Calling the spinner is a one line thing as well.

Author:  crudball [ Sat Apr 08, 2006 10:54 am ]
Post subject: 

that doesnt spin!
terminal wrote:
[[email protected] rob]# ./spin
+++++++++++++++[[email protected] rob]#

Author:  crouse [ Sat Apr 08, 2006 11:53 am ]
Post subject: 

Code:
#!/bin/bash
spin ()
{
BLUE='\e[0;34m'
RED='\e[0;31m'
WHITE='\e[1;37m'
NC='\e[0m'

echo -ne "${RED}-"
echo -ne "${WHITE}\b|"   
echo -ne "${BLUE}\bx"
sleep .3
echo -ne "${RED}\b+${NC}"
}

for i in `seq 1 15` ; do spin; done


does more of a progress bar thing than just sitting and spinning.....

and another version of this.....

Code:
#!/bin/bash
function spin {
    echo -n '-'
    echo -ne '\b|'   
    sleep .1
    echo -ne '\bx'
    sleep .1
    echo -ne '\b+'
}
for i in `seq 1 15` ; do spin; done   
echo ""
exit

Author:  jbsnake [ Sat Apr 08, 2006 12:05 pm ]
Post subject: 

i like this one... you have to cntrl+C it... but it's kinda cool... and was used in a couple scripts that take awhile...
Code:
#!/bin/bash

shopt -s -o nounset
trap 'echo -e "\b\b\b\b\b\b\b\b\b|=======|> done!"' EXIT
        echo -n "|/     |"
        while true
        do
        # moving right
        echo -ne "\b\b\b\b\b\b\b-     |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b\\     |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b|     |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b /    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b-    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\\    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b|    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b /   |"
        sleep .03
        echo -ne "\b\b\b\b\b-   |"
        sleep .03
        echo -ne "\b\b\b\b\b\\   |"
        sleep .03
        echo -ne "\b\b\b\b\b|   |"
        sleep .03
        echo -ne "\b\b\b\b\b /  |"
        sleep .03
        echo -ne "\b\b\b\b-  |"
        sleep .03
        echo -ne "\b\b\b\b\\  |"
        sleep .03
        echo -ne "\b\b\b\b|  |"
        sleep .03
        echo -ne "\b\b\b\b / |"
        sleep .03
        echo -ne "\b\b\b- |"
        sleep .03
        echo -ne "\b\b\b\\ |"
        sleep .03
        echo -ne "\b\b\b| |"
        sleep .03
        echo -ne "\b\b\b /|"
        sleep .03
        echo -ne "\b\b-|"
        sleep .03
        echo -ne "\b\b\\|"
        sleep .03
        echo -ne "\b\b||"
        sleep .03
        echo -ne "\b\b/|"
        sleep .03

        # moving left
        echo -ne "\b\b||"
        sleep .03
        echo -ne "\b\b\\|"
        sleep .03
        echo -ne "\b\b-|"
        sleep .03
        echo -ne "\b\b\b/ |"
        sleep .03
        echo -ne "\b\b\b| |"
        sleep .03
        echo -ne "\b\b\b\\ |"
        sleep .03
        echo -ne "\b\b\b- |"
        sleep .03
        echo -ne "\b\b\b\b/  |"
        sleep .03
        echo -ne "\b\b\b\b|  |"
        sleep .03
        echo -ne "\b\b\b\b\\  |"
        sleep .03
        echo -ne "\b\b\b\b-  |"
        sleep .03
        echo -ne "\b\b\b\b\b/   |"
        sleep .03
        echo -ne "\b\b\b\b\b|   |"
        sleep .03
        echo -ne "\b\b\b\b\b\\   |"
        sleep .03
        echo -ne "\b\b\b\b\b-   |"
        sleep .03
        echo -ne "\b\b\b\b\b\b/    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b|    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\\    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b-    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b/     |"
        sleep .03
        done

Author:  crudball [ Sun Apr 09, 2006 6:02 am ]
Post subject: 

Heres a nice one:
Code:
#!/bin/bash
search ()
{
        delay1='sleep .08'
   wipescreen='echo -ne \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b'
echo -ne "c       ";$delay1;$wipescreen
echo -ne "cr      ";$delay1;$wipescreen
echo -ne "cru     ";$delay1;$wipescreen
echo -ne "crud    ";$delay1;$wipescreen
echo -ne "crudb   ";$delay1;$wipescreen
echo -ne "crudba  ";$delay1;$wipescreen
echo -ne "crudbal ";$delay1;$wipescreen
echo -ne "crudball";$delay1;$wipescreen
echo -ne " rudball";$delay1;$wipescreen
echo -ne "  udball";$delay1;$wipescreen
echo -ne "   dball";$delay1;$wipescreen
echo -ne "    ball";$delay1;$wipescreen
echo -ne "     all";$delay1;$wipescreen
echo -ne "      ll";$delay1;$wipescreen
echo -ne "       l";$delay1;$wipescreen
echo -ne "        ";$delay1;$wipescreen
search
}
search

Author:  crudball [ Mon Jun 12, 2006 10:16 am ]
Post subject: 

Here is a clock using the same basic format:
Code:

#!/bin/bash
clock ()
{
        delay1='sleep 1'
   wipescreen='echo -ne
\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\$
echo -ne "`date +"%H:%M:%S"`";$delay1 ;$wipescreen
clock
}
clock

The date command can be modified to suite - man date or date --help.

Author:  Nostur [ Mon Nov 20, 2006 2:54 pm ]
Post subject: 

can i ask, if i want to use the spinner, until, lets say nmap finishes run, how will you manage to stop it after nmap completes scan ?

Author:  donnied [ Sun Nov 18, 2007 9:14 am ]
Post subject: 

This would be interesting to show in the terminal possibly in front of the prompt. & does it half way but the output interferes with the information at the prompt.

Author:  pDragoon [ Thu Aug 28, 2008 5:16 am ]
Post subject: 

This is in reply to

if i want to use the spinner, until, lets say nmap finishes run, how will you manage to stop it after nmap completes scan ?

well you could do that by puttin it in while loop, like

while ( ps -aef | grep "nmap" 1>/dev/null )

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com