-
-
Save ziishaned/83f8c9a992b367d8620c2cc7f4536f95 to your computer and use it in GitHub Desktop.
bash spinner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
spinner() { | |
local cl="\r\033[K" | |
local pid=$1 | |
local spinnging=true | |
local delay=0.05 | |
local spinstr="⠏⠛⠹⠼⠶⠧" | |
printf " " | |
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do | |
local tmp=${spinstr#?} | |
if [ -z "$2" ]; then | |
printf " \b\b\b${tmp:0:1} " | |
else | |
printf "${cl} ${tmp:0:1} ${2}" | |
fi | |
local spinstr=$tmp${spinstr%"$tmp"} | |
sleep $delay | |
done | |
printf "${cl}" | |
} | |
(sleep 4) & | |
spinner $! "Updating pro-cli ..." | |
(sleep 4) & | |
printf "Updating ..." && spinner $! | |
printf "end\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment