bashrc/.bashrc.d/countdown.bash

16 lines
251 B
Bash
Raw Normal View History

countdown() {
if [ -z "$1" ]; then
printf "
countdown: Count down while printing progress on the terminal
Usage: countdown <seconds>
"
fi
local secs="$1"
while [ "$secs" -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
}