a tiny CLI timer in 12 lines
a quick shell one‑liner I actually use
Sometimes I just need a quick timer from the terminal with a friendly beep and a desktop notification. This is a tiny Bash function you can drop into your shell profile.
timer() {
local mins=${1:-5}
local secs=$((mins*60))
while [ $secs -gt 0 ]; do
printf "\r⏳ %02d:%02d " $((secs/60)) $((secs%60))
sleep 1; : $((secs--))
done
printf "\r✅ done! \n"; tput bel
command -v notify-send >/dev/null && notify-send "Timer" "${mins} min done"
}
Usage: timer 10 for ten minutes, or just timer for the default five. I keep this in .bashrc and .zshrc.
Similar Posts
Here are some more articles you might like to read next: