summaryrefslogtreecommitdiff
path: root/etc/functions/countdown
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-03-19 09:13:55 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-03-19 09:13:55 +0100
commitefaeb390d847eeffde05a80c97c05eef0c9535b0 (patch)
treee151a073e16f52da5c08941e94138dfb80a905d0 /etc/functions/countdown
parent5bc0209f52842c24adbfd9de59462856a3fc7f3c (diff)
countdown: Fancier display of remaining time
Diffstat (limited to 'etc/functions/countdown')
-rwxr-xr-xetc/functions/countdown5
1 files changed, 3 insertions, 2 deletions
diff --git a/etc/functions/countdown b/etc/functions/countdown
index 3c8bba9..28639f4 100755
--- a/etc/functions/countdown
+++ b/etc/functions/countdown
@@ -1,7 +1,8 @@
## vim:ft=zsh
## Countdown to a specific date/time
## Usage: countdown <string understood by 'date -d'>
-## Copyright (C) 2008 by Daniel Friesel <derf@derf.homelinux.org>
+## or: countdown +<seconds>
+## Copyright (C) 2008-2009 by Daniel Friesel <derf@derf.homelinux.org>
## License: WTFPL <http://sam.zoy.org/wtfpl>
autoload check_com
@@ -21,7 +22,7 @@ if [[ $1 == +* ]] {
while true; do
seconds=$[$(date -d $date +%s)-$(date +%s)]
- echo -n $seconds
+ printf '%02d:%02d:%02d' $((seconds/3600)) $(((seconds/60)%60)) $((seconds%60))
if (( seconds <= 0 )) {
(( beep )) && beep || echo -ne "\a"
}