Created
April 14, 2021 21:16
-
-
Save iamsilvio/84cb8aa5c85f340c1cf2b5bafb9a4462 to your computer and use it in GitHub Desktop.
ZSH 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
ct5() { | |
AWESOME_COUNTDOWN=$(date --date 'now + 5 minutes' +%s) | |
} | |
ct90() { | |
AWESOME_COUNTDOWN=$(date --date 'now + 90 minutes' +%s) | |
} |
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
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