Skip to content

Instantly share code, notes, and snippets.

@svandragt
Last active May 28, 2020
Embed
What would you like to do?
countdown cli
#!/usr/bin/env bash
# v3 - 2020-05-28
if [ $# -eq 0 ]; then
echo "countdown.sh <seconds> \"<message>\""
exit 1
fi
secs=$1
msg=${2:-$1 seconds passed.}
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
title="Countdown Finished"
if [ -x "$(command -v notify-send)" ]; then
notify-send "$title" "$msg"
fi
if [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "$title" -message "$msg"
fi
echo "$title: $msg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment