This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/bin/countdown

16 lines
360 B
Plaintext
Raw Normal View History

2019-09-25 07:16:15 -05:00
#!/usr/bin/env bash
2020-05-18 15:34:35 -05:00
[[ -z "${@}" ]] && { echo "No argument provided." >&2 ; exit 1; }
2020-04-20 10:38:19 -05:00
d=$(($(date +%s) + $1));
echo "Countdown started at $(date)"
2019-09-25 07:16:15 -05:00
2020-04-20 10:38:19 -05:00
while [[ "$d" -ge "$(date +%s)" ]]; do
_dt=$((d - $(date +%s)))
2019-09-25 07:16:15 -05:00
days=$((_dt / 86400))
2020-04-20 10:38:19 -05:00
echo -ne "\r${days}d $(date -u --date @$((_dt)) +%H:%M:%S) ";
2019-09-25 07:16:15 -05:00
sleep 0.1
done
echo -ne "\rCountdown finished $(date)\n"