Skip to content

Instantly share code, notes, and snippets.

@svandragt
Last active May 28, 2020 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svandragt/0fefef685b36e23ef4b5fa4330febcb8 to your computer and use it in GitHub Desktop.
Save svandragt/0fefef685b36e23ef4b5fa4330febcb8 to your computer and use it in GitHub Desktop.
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