Skip to content

Instantly share code, notes, and snippets.

@antoninhrlt
Last active March 27, 2021 00:34
Show Gist options
  • Save antoninhrlt/c0c341a2102914aabd3ab4004889cf8c to your computer and use it in GitHub Desktop.
Save antoninhrlt/c0c341a2102914aabd3ab4004889cf8c to your computer and use it in GitHub Desktop.
Real bash loader. Result : https://www.youtube.com/watch?v=ff7SQ0y-Sng
#
# From Antonin Hérault
# https://github.com/antoninhrlt
#
function bash-loader()
{
if [[ -z $1 ]]
then
local text="undefined text"
else
local text=$1
fi
if [[ -z $2 ]]
then
local sp=". "
else
local sp=$2
fi
PID=$!
local i=1
echo -n " "
while [ -d /proc/$PID ]
do
printf "\r${text} ${sp:i--%${#sp}:1} ${sp:i++%${#sp}:1} ${sp:i--%${#sp}:1}\t"
sleep .3 # Does not affect the execution time in any way!
done
}
# _____________________________________________________________________________________
# Usage :
# your command here &
bash-loader "My text"
# or (to change symbol)
# your command here &
bash-loader "My text" " # "
# Example :
echo "Start compile"
g++ src/main.cpp -o bin/prog & # Don't forget "&" symbol !
bash-loader "Compilation"
echo -e "\nFinish !"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment