Last active
December 28, 2015 18:49
-
-
Save ilguzin/7546043 to your computer and use it in GitHub Desktop.
Progress bar (dots...) on operations execution
This file contains hidden or 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
# | |
# 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