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