diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-12-05 18:36:10 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-12-05 18:36:10 +0100 |
commit | 0b5b3e2d788b6c6f8819181d20f47165004ec3b6 (patch) | |
tree | d4403c91e8b88f688c28c37a811d9eebdee797ef /etc/functions/countdown | |
parent | 3a9f2496016e5ab61bd12080cc301362cbaf80b0 (diff) |
Re-added countdown function
Diffstat (limited to 'etc/functions/countdown')
-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 |