Skip to content

Instantly share code, notes, and snippets.

@cyrbil
Created April 14, 2015 11:56
Show Gist options
  • Save cyrbil/0be26032566ea2179f27 to your computer and use it in GitHub Desktop.
Save cyrbil/0be26032566ea2179f27 to your computer and use it in GitHub Desktop.
spinner () {
local pid=$1
local speed=${2:-.1}
local text=$3
local spin="⢎⡰⢎⡡⢎⡑⢎⠱⠎⡱⢊⡱⢌⡱⢆⡱"
local i=0
while kill -0 "$pid" 2>/dev/null
do
local i=$(( (i+1) % 8))
local c1=$(echo $spin | cut -c$(( i*6+1 ))-$(( i*6+3 )))
local c2=$(echo $spin | cut -c$(( i*6+4 ))-$(( i*6+6 )))
printf "\r$3$c1$c2"
sleep "$speed"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment