Skip to content

Instantly share code, notes, and snippets.

@braddle
Created August 17, 2023 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddle/29b7076510427b21549c9593e1bd8dcf to your computer and use it in GitHub Desktop.
Save braddle/29b7076510427b21549c9593e1bd8dcf to your computer and use it in GitHub Desktop.
Interruptible countdown timer
#!/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