Last active
May 28, 2020 14:29
-
-
Save svandragt/0fefef685b36e23ef4b5fa4330febcb8 to your computer and use it in GitHub Desktop.
countdown cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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