Skip to content

Instantly share code, notes, and snippets.

@yudai09
Created May 15, 2017 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yudai09/7d5242c9d5f7d36c5d1f1caab9b7aeb7 to your computer and use it in GitHub Desktop.
Save yudai09/7d5242c9d5f7d36c5d1f1caab9b7aeb7 to your computer and use it in GitHub Desktop.
# spinner characters
# http://stackoverflow.com/questions/2685435/cooler-ascii-spinners
# spinner code
# https://github.com/IntellexApps/blcheck.git
# Define spinner
#SPINNER="-\|/"
#SPINNER=".oO@*"
#SPINNER="▉▊▋▌▍▎▏▎▍▌▋▊▉"
#SPINNER="←↖↑↗→↘↓↙"
#SPINNER="▁▂▃▄▅▆▇█▇▆▅▄▃▁"
#SPINNER="▖▘▝▗"
#SPINNER="┤┘┴└├┌┬┐"
#SPINNER="◢◣◤◥"
#SPINNER="▤▥▦▧"
#SPINNER="⣾⣽⣻⢿⡿⣟⣯⣷"
#SPINNER="⠁⠂⠄⡀⢀⠠⠐⠈"
#SPINNER="◰◳◲◱"
#SPINNER="◴◷◶◵"
SPINNER="◐◓◑◒"
# Show progres
progress() {
# Bar
x=$(($1 % ${#SPINNER} + 1))
BAR=$(echo $SPINNER | awk "{ print substr(\$0, ${x}, 1) }")
if test -z "$PLAIN"; then
printf "\r ";
fi
# BAR as printf arg so that backslash will be litteraly interpreted
printf "[ %s %3s%% ] checking... %4s / $2 " "$BAR" $(($1 * 100 / $2)) "$1";
}
main() {
i=0;
max=100;
for i in $(seq $max); do
progress "$i" "$max"
sleep 0.1
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment