From b80c1ad978a11e85a96b02008a222a7a0a78c298 Mon Sep 17 00:00:00 2001 From: kneutron <50146127+kneutron@users.noreply.github.com> Date: Tue, 15 Jun 2021 08:40:01 -0500 Subject: [PATCH] Add files via upload --- countdown.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 countdown.sh diff --git a/countdown.sh b/countdown.sh new file mode 100644 index 0000000..92cce04 --- /dev/null +++ b/countdown.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# 2020 Dave Bechtel +# Display a rotating-prompt countdown with keypress early escape +# REF: https://stackoverflow.com/questions/12498304/using-bash-to-display-a-progress-indicator + +# number +declare -i countto=$1 +ctr=0 + +# array +declare -a spin +spin[0]="-" +spin[1]='\' +spin[2]="|" +spin[3]="/" + +echo -n "[$countto] ${spin[0]} " #$ctr" + +while [ $countto -ge $ctr ]; do + for i in "${spin[@]}" + do + let cdown=$countto-$ctr + printf "\r$countto $i $cdown " + sleep 1 + let ctr=$ctr+1 + [ $ctr -ge $countto ] && break + read -n 1 -t .1 && break 2 +# ESC if key pressed + done +done +echo ''