Skip to content

Instantly share code, notes, and snippets.

@busterc
Last active January 12, 2018 15:33
Show Gist options
  • Save busterc/6e0d31169ce552b41854 to your computer and use it in GitHub Desktop.
Save busterc/6e0d31169ce552b41854 to your computer and use it in GitHub Desktop.
countdown timer for bash #bash
#!/bin/bash
function timer() {
if [[ $1 -lt 1 ]]; then
cat <<EOF
Usage: timer <seconds>
EOF
return 1
fi
local n="$1"
while [[ $n -gt 0 ]]; do
printf "\r\033[0K==> $n"
sleep 1
((n--))
done
printf "\r\a"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment