Skip to content

Instantly share code, notes, and snippets.

@ilguzin
Last active December 28, 2015 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilguzin/7546043 to your computer and use it in GitHub Desktop.
Save ilguzin/7546043 to your computer and use it in GitHub Desktop.
Progress bar (dots...) on operations execution
#
# Utilities
#
dot_progress() {
while true
do
echo -n "."
sleep 2
done
}
start_progress() {
dot_progress &
PROGRESS=$!
}
stop_progress(){
disown $PROGRESS # disown the PROGRESS process for suppressing system "Terminated output"
kill $PROGRESS &> /dev/null # Suppress output
}
#
# Use case
#
echo -n "Do something for a long time"
start_progress
# A job spending time start
sleep 10
echo "done"
# Job end
stop_progress
######
# output:
# Do something for a long time......done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment