bashrc/.bashrc.d/countdown.sh

16 lines
251 B
Bash

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
}