Skip to content

Instantly share code, notes, and snippets.

@juunini
Last active January 31, 2023 07:47
Show Gist options
  • Save juunini/91ce1b4062d102a0cbc42a49bc34fb51 to your computer and use it in GitHub Desktop.
Save juunini/91ce1b4062d102a0cbc42a49bc34fb51 to your computer and use it in GitHub Desktop.
Loading animation in shell script
#! /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