diff options
-rwxr-xr-x | etc/functions/countdown | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/etc/functions/countdown b/etc/functions/countdown new file mode 100755 index 0000000..a4c4a26 --- /dev/null +++ b/etc/functions/countdown @@ -0,0 +1,18 @@ +## vim:ft=zsh +autoload check_com +typeset -i beep=0 +typeset -i seconds + +if check_com beep; then + beep=1 +fi + +while true; do + seconds=$[$(date -d "$*" +%s)-$(date +%s)] + echo -n $seconds + if (( seconds <= 0 )) { + (( beep )) && beep || echo -ne "\a" + } + sleep 1 + echo -ne "\r\e[2K" +done |