Advertisement
metalx1000

BASH Spinner visual progress bar

May 7th, 2015
5,127
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 1 0
  1. #!/bin/bash
  2.  
  3. clear
  4. spinner=( Ooooo oOooo ooOoo oooOo ooooO oooOo ooOoo oOooo);
  5.  
  6. cat << EOF
  7. Hello.
  8. Thank you for trying this script out.
  9. I will now wait 10 seconds,
  10. but you will see a "spinner"
  11. as a visual for the user.
  12. EOF
  13.  
  14.  
  15. count(){
  16.   spin &
  17.   pid=$!
  18.  
  19.   for i in `seq 1 10`
  20.   do
  21.     sleep 1;
  22.   done
  23.  
  24.   kill $pid  
  25. }
  26.  
  27. spin(){
  28.   while [ 1 ]
  29.   do
  30.     for i in ${spinner[@]};
  31.     do
  32.       echo -ne "\r$i";
  33.       sleep 0.2;
  34.     done;
  35.   done
  36. }
  37.  
  38. count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement