Skip to content

Instantly share code, notes, and snippets.

@aussielunix
Created July 25, 2020 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aussielunix/8094684f3770ed9e636915f751fd4418 to your computer and use it in GitHub Desktop.
Save aussielunix/8094684f3770ed9e636915f751fd4418 to your computer and use it in GitHub Desktop.
# Run a command and present a spiiner whilst it completes
#
apt-get update -qq & # important to background command
pid=$! # get PID of backgrounded task
spin[0]="-"
spin[1]="\\"
spin[2]="|"
spin[3]="/"
echo -n "[updating APT sources] ${spin[0]}"
while kill -0 $pid 2>/dev/null
do
i=$(( (i+1) %4 ))
echo -ne "\b${spin[$i]}"
sleep 0.1
done
echo -e "\bDONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment