Skip to content

Instantly share code, notes, and snippets.

@xemoe
Created June 4, 2015 06:41
Show Gist options
  • Save xemoe/2019cb0e619f94071a16 to your computer and use it in GitHub Desktop.
Save xemoe/2019cb0e619f94071a16 to your computer and use it in GitHub Desktop.
Bash spinner
spinner()
{
    local pid=$1
    local delay=0.75
    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"
}

sleep 10 & spinner $!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment