Skip to content

Instantly share code, notes, and snippets.

@rickycodes
Created January 21, 2020 20:09
Show Gist options
  • Save rickycodes/44010570b08a1c853d102f7bec182648 to your computer and use it in GitHub Desktop.
Save rickycodes/44010570b08a1c853d102f7bec182648 to your computer and use it in GitHub Desktop.
countdown alias
# usage `countdown seconds` eg: `countdown 10` `countdown 60*15` etc.
countdown() {
_date=$((`date +%s` + $1));
while [ "$_date" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($_date - `date +%s`)) +%H:%M:%S)\r";
sleep 0.1
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment