Skip to content

Instantly share code, notes, and snippets.

@iamsilvio
Created April 14, 2021 21:16
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 iamsilvio/84cb8aa5c85f340c1cf2b5bafb9a4462 to your computer and use it in GitHub Desktop.
Save iamsilvio/84cb8aa5c85f340c1cf2b5bafb9a4462 to your computer and use it in GitHub Desktop.
ZSH Countdown Timer
ct5() {
AWESOME_COUNTDOWN=$(date --date 'now + 5 minutes' +%s)
}
ct90() {
AWESOME_COUNTDOWN=$(date --date 'now + 90 minutes' +%s)
}
function check_timer {
if [[ $AWESOME_COUNTDOWN ]] && [ $AWESOME_COUNTDOWN -eq $AWESOME_COUNTDOWN ] 2>/dev/null
then
tnow=$(date +%s)
if [ $AWESOME_COUNTDOWN -gt $tnow ]
then
tleft=$(( $AWESOME_COUNTDOWN - $tnow))
eval "echo $(date -ud "@$tleft" +'%H:%M:%S')"
else
unset $AWESOME_COUNTDOWN
fi
fi
}
RPROMPT='$(check_timer)'
TMOUT=1
TRAPALRM() {
zle reset-prompt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment