Last active
September 3, 2015 16:39
-
-
Save netmute/308423ea435ff0df53a4 to your computer and use it in GitHub Desktop.
a simple spinning animation for your shell scripts
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 | |
# | |
# a simple spinning animation for your shell scripts | |
# prints message in front of spinner | |
# - argument 1: the message to print | |
spinner_init() { | |
printf "$1 " | |
} | |
# renders spinner animation once for 0.4 seconds | |
spinner_spin() { | |
printf "\b/" | |
sleep 0.1 | |
printf "\b-" | |
sleep 0.1 | |
printf "\b\\" | |
sleep 0.1 | |
printf "\b|" | |
sleep 0.1 | |
} | |
# prints message after the spinner | |
# - argument 1: the message to print | |
spinner_done() { | |
printf "\b\b: $1\n" | |
} | |
# use it like this | |
spinner_init "Waiting for demo.txt" | |
while [ ! -f "./demo.txt" ]; do | |
spinner_spin | |
done | |
spinner_done "found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment