Skip to content

Instantly share code, notes, and snippets.

@rickd-uk
Created March 15, 2021 02:36
Show Gist options
  • Save rickd-uk/225a4b813f2e7a5eb7c4e81b912ade1c to your computer and use it in GitHub Desktop.
Save rickd-uk/225a4b813f2e7a5eb7c4e81b912ade1c to your computer and use it in GitHub Desktop.
BASH SPINNER 2
**ANOTHER SPINNER**
#!/bin/sh
#The command you are waiting on goes between the ( ) here
#The example below returns a non zero return code
(sleep 20 ; /bin/false) &
pid=$! ; i=0
while ps -a | awk '{print $1}' | grep -q "${pid}"
do
c=`expr ${i} % 4`
case ${c} in
0) echo "/\c" ;;
1) echo "-\c" ;;
2) echo "\\ \b\c" ;;
3) echo "|\c" ;;
esac
i=`expr ${i} + 1`
# change the speed of the spinner by altering the 1 below
sleep 1
echo "\b\c"
done
#Collect the return code from the background process
wait ${pid}
ret=$?
#You can report on any errors due to a non zero return code here
exit ${ret}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment