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/at

21 lines
513 B
Plaintext
Raw Normal View History

2020-05-18 15:34:35 -05:00
#!/usr/bin/env bash
2022-12-01 17:17:50 -06:00
usage() {
2023-07-17 11:23:37 -05:00
echo "at - waits until after the specified datetime"
2022-12-01 17:17:50 -06:00
echo "Usage:"
2023-07-17 11:23:37 -05:00
echo " at <DATETIME> && command..."
echo
echo "Examples:"
echo " at 15:00:00 && echo \"it is 3 o'clock\""
2022-12-01 17:17:50 -06:00
}
[[ -z "$1" ]] && { echo "Error: No DATE argument provided." >&2; usage; exit 1; }
2020-05-18 15:34:35 -05:00
d="$(date -d "${@}" +%s)"
while [[ "$d" -ge "$(date +%s)" ]]; do
_dt=$((d - $(date +%s)))
days=$((_dt / 86400))
echo -ne "\rTime Remaining: ${days}d $(date -u --date @$((_dt)) +%H:%M:%S) ";
sleep 0.1
2023-07-17 11:23:37 -05:00
done
exit 0