Skip to content

Instantly share code, notes, and snippets.

@jveldboom
Created February 24, 2013 03:15
Show Gist options
  • Save jveldboom/5022422 to your computer and use it in GitHub Desktop.
Save jveldboom/5022422 to your computer and use it in GitHub Desktop.
Bash Loading Spinner
#!/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