summaryrefslogtreecommitdiff
path: root/etc/functions/countdown
blob: a4c4a26c5dcd2bd269f4d17a445e3628eb4d3f71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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