Created
August 17, 2023 10:54
-
-
Save braddle/29b7076510427b21549c9593e1bd8dcf to your computer and use it in GitHub Desktop.
Interruptible countdown timer
This file contains 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
#!/bin/bash | |
interruptLoop() { | |
countdown=10 | |
until read -s -n 1 -t 1; do | |
if [ $countdown -eq 0 ]; then break; fi | |
prefix="\033[0;34m " | |
if [ $countdown -lt 6 ]; then prefix="\a\033[1;35m "; fi | |
echo -ne "$prefix Time til next run $countdown\033[0K\r" | |
((countdown = countdown - 1)) | |
done | |
} | |
while true; | |
do | |
interruptLoop | |
clear | |
echo "RUNNING..." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment