Created
February 24, 2013 03:15
-
-
Save jveldboom/5022422 to your computer and use it in GitHub Desktop.
Bash Loading Spinner
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
#!/bin/bash | |
spinner() | |
{ | |
local pid=$1 | |
local delay=0.4 | |
local spinstr='|/-\' | |
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do | |
local temp=${spinstr#?} | |
printf " [%c] " "$spinstr" | |
local spinstr=$temp${spinstr%"$temp"} | |
sleep $delay | |
printf "\b\b\b\b\b\b" | |
done | |
printf " \b\b\b\b" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment