Created
December 24, 2017 15:26
-
-
Save dphov/21b5fc7bbc16e9532a97c9790aad00d4 to your computer and use it in GitHub Desktop.
POSIX shell compatible countdown timer. Credits to @cfajohnson
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
countdown() | |
( | |
IFS=: | |
set -- $* | |
secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} )) | |
while [ $secs -gt 0 ] | |
do | |
sleep 1 & | |
printf "\r%02d:%02d:%02d" $((secs/3600)) $(( (secs/60)%60)) $((secs%60)) | |
secs=$(( $secs - 1 )) | |
wait | |
done | |
echo | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment