Created
September 4, 2015 08:37
-
-
Save abcarroll/5a55225e24d9225a5742 to your computer and use it in GitHub Desktop.
Countdown with
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
countsheep(){ | |
hr=$1 | |
min=$2 | |
sec=$3 | |
if [ -z "$4" ] | |
then | |
prefix="" | |
else | |
prefix="$4" | |
fi | |
while [ $hr -ge 0 ]; do | |
while [ $min -ge 0 ]; do | |
while [ $sec -ge 0 ]; do | |
echo -ne "${prefix}$(printf %02d "$hr"):$(printf %02d "$min"):$(printf %02d "$sec")\033[0K" | |
sec=$((sec-1)) | |
sleep 1 | |
echo -ne "\r" | |
done | |
sec=59 | |
min=$((min-1)) | |
done | |
hr=$((hr-1)) | |
done | |
} | |
# Usage: | |
# coutnsheep h m s "Prefix if desired" | |
# example: | |
# countsheep 1 30 0 "Time until next action: " | |
# will print: | |
# Time Until next action: 01:30:00 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment