-
-
Save iamtew/dd29a14723e14b0633581ea2d90c5c6d to your computer and use it in GitHub Desktop.
Super Spinner: An Emoji-based spinner for bash
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
### | |
# Super Spinner | |
# An emoji-based spinner β because ASCII is boring. | |
# | |
# Usage: | |
# $ COMMAND & superSpinner $! "Message" | |
# | |
# Example: | |
# $ sleep 5 & superSpinner $! "Sleeping for 5 seconds" | |
# | |
# Output: | |
# $ π Sleeping for 5 seconds... | |
# $ π₯ Sleeping for 5 seconds.... Finished! | |
### | |
superSpinner() { | |
local PID=$1 | |
local CLOCK_STR=("π" "π" "π" "π" "π" "π" "π" "π" "π" "π" "π" "π") | |
local INDEX=0 | |
tput civis | |
echo -ne "\r" | |
while kill -0 "$PID" 2> /dev/null ; do | |
echo -ne "${CLOCK_STR[$INDEX]} $2...\r" | |
INDEX=$(( INDEX == 11 ? 0 : INDEX + 1 )) | |
sleep 0.08333333333 | |
done | |
echo -ne "\rπ₯ $2.... Finished!" | |
echo | |
tput cnorm | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment