Last active
December 13, 2022 15:12
-
-
Save geoffrepoli/14966c8e7cd33386b917cc30dd919135 to your computer and use it in GitHub Desktop.
function you can place in your scripts and call on any command where you want progress animations. replaced the earlier snippet that was less plug and play. the characters in $loop can be replaced with other characters - printf prints 3 individual random characters from the string stored in $loop
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
_progressBar() { | |
local pid="$1" | |
if ps -p "$pid" &>/dev/null; then | |
loop='▁▃▄▅▆▇█' | |
while kill -0 "$pid" &>/dev/null; do | |
printf "%b\r" "${loop:$((RANDOM%${#loop})):1}${loop:$((RANDOM%${#loop})):1}${loop:$((RANDOM%${#loop})):1}" | |
sleep 0.1 | |
done | |
fi | |
} | |
yourcommand & | |
_progressBar $! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment