Last active
August 31, 2023 21:46
-
-
Save ssg/5c8c5ac0326f5771af627ed38d32c422 to your computer and use it in GitHub Desktop.
APT style progress bar
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 | |
# progress bar function | |
prog() { | |
local w=80 p=$1; shift | |
# create a string of spaces, then change them to dots | |
printf -v dots "%*s" "$(( $p*$w/100 ))" ""; dots=${dots// /\#}; | |
# print those dots on a fixed-width space plus the percentage etc. | |
printf "\r\e[K|%-*s| %3d %% %s" "$w" "$dots" "$p" "$*"; | |
} | |
# test loop | |
for x in {1..100} ; do | |
prog "$x" still working... | |
sleep .1 # do some work here | |
done ; echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I created this to reproduce the false ligatures problem with Berkeley Mono font and apt's progress bar.