Last active
January 31, 2023 07:47
Loading animation in shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
LOADING=("\\" "|" "/" "-") | |
loading() { | |
printf "%s \b\b" ${LOADING[$(( $1 % 4 ))]} | |
} | |
# Usage | |
: << "END" | |
i=0 | |
while : | |
do | |
if [[ finish statement ]]; then | |
echo " " | |
break | |
fi | |
loading $1 | |
(( i += 1 )) | |
sleep 1s | |
done | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment