diff options
author | William Harrington <kb0iic@berzerkula.org> | 2021-04-01 12:16:39 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2021-04-01 12:16:39 -0500 |
commit | c7651e10b510157286effc055d6ce0c86d9e995c (patch) | |
tree | 15ab0fe8a45645a9f984892e9fe7a746c6a3dfa9 /functions.sh | |
parent | dc161b4d4f5c37c2e72a953e639641b112fb68a0 (diff) | |
parent | 0f7d778bfe357bd031249165d69561a5f92a0d8a (diff) |
Merge branch 'cleanup' into chapter7
Diffstat (limited to 'functions.sh')
-rw-r--r-- | functions.sh | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/functions.sh b/functions.sh index 8c5bd93..46bb58a 100644 --- a/functions.sh +++ b/functions.sh @@ -33,56 +33,68 @@ function cursorBack() { function spinner() { # make sure we use non-unicode character type locale # (that way it works for any locale as long as the font supports the characters) + local numspinners=12 + local LC_CTYPE=C local pid=$1 # Process Id of the previous running command - case $(($RANDOM % 12)) in + local spintype=$2 + + if [ -z "${spintype}" ] || [ "${spintype}" -ge "${numspinners}" ]; then + spintype=$((RANDOM % numspinners)) + fi + + case "${spintype}" in 0) - local spin='⠁⠂⠄⡀⢀⠠⠐⠈' - local charwidth=3 + local spin='.oO0Oo' + local charwidth=1 ;; 1) local spin='-\|/' local charwidth=1 ;; 2) - local spin="▁▂▃▄▅▆▇█▇▆▅▄▃▂▁" + local spin='⠁⠂⠄⡀⢀⠠⠐⠈' local charwidth=3 ;; 3) - local spin="▉▊▋▌▍▎▏▎▍▌▋▊▉" + local spin="▁▂▃▄▅▆▇█▇▆▅▄▃▂▁" local charwidth=3 ;; 4) - local spin='←↖↑↗→↘↓↙' + local spin="▉▊▋▌▍▎▏▎▍▌▋▊▉" local charwidth=3 ;; 5) - local spin='▖▘▝▗' + local spin='←↖↑↗→↘↓↙' local charwidth=3 ;; 6) - local spin='┤┘┴└├┌┬┐' + local spin='▖▘▝▗' local charwidth=3 ;; 7) - local spin='◢◣◤◥' + local spin='┤┘┴└├┌┬┐' local charwidth=3 ;; 8) - local spin='◰◳◲◱' + local spin='◢◣◤◥' local charwidth=3 ;; 9) - local spin='◴◷◶◵' + local spin='◰◳◲◱' local charwidth=3 ;; 10) - local spin='◐◓◑◒' + local spin='◴◷◶◵' local charwidth=3 ;; 11) + local spin='◐◓◑◒' + local charwidth=3 + ;; + 12) local spin='⣾⣽⣻⢿⡿⣟⣯⣷' local charwidth=3 ;; @@ -96,9 +108,9 @@ function spinner() { printf "%b" "${spin:$i:$charwidth}" cursorBack 1 - sleep .1 + sleep .2 done tput cnorm - wait $pid # capture exit code + wait "$pid" # capture exit code return $? } |