Created
January 5, 2014 16:33
-
-
Save coderofsalvation/8270356 to your computer and use it in GitHub Desktop.
bash animation function
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
# tar zxf big_file.tar.gz > /dev/null 2>&1 & | |
# printf "%s" "[+] tar is running ..." && _animcui $(pidof tar) | |
showanim() | |
{ | |
[ -z "$1" ] && { printf "%5s\n" ""; return 1; } | |
printf "%s\\n" "$1" | grep -v "[^0-9]" >/dev/null || { printf "%5s\n" ""; return 1; } | |
_animcui_var_pid="$1" | |
_animcui_var_animation_state=1 | |
if [ ! "$(ps -p $_animcui_var_pid -o comm=)" ]; then | |
printf "%5s\n" "" | |
return 1 | |
fi | |
printf "%s" " " | |
while [ "$(ps -p $_animcui_var_pid -o comm=)" ]; do | |
printf "%b" "\b\b\b\b\b" | |
case $_animcui_var_animation_state in | |
1) | |
printf "%s" '\o@o\' | |
_animcui_var_animation_state=2 | |
;; | |
2) | |
printf "%s" '|o@o|' | |
_animcui_var_animation_state=3 | |
;; | |
3) | |
printf "%s" '/o@o/' | |
_animcui_var_animation_state=4 | |
;; | |
4) | |
printf "%s" '|o@o|' | |
_animcui_var_animation_state=1 | |
;; | |
esac | |
sleep 1 | |
done | |
printf "%b" "\b\b\b\b\b" && printf "%5s\n" "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment