Last active
August 17, 2022 08:59
-
-
Save zulaica/9e971cc5b6dbd156abcd13745beff262 to your computer and use it in GitHub Desktop.
Super Spinner: An Emoji-based spinner for bash
This file contains hidden or 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