Skip to content

Instantly share code, notes, and snippets.

@ssg
Last active August 31, 2023 21:46
Show Gist options
  • Save ssg/5c8c5ac0326f5771af627ed38d32c422 to your computer and use it in GitHub Desktop.
Save ssg/5c8c5ac0326f5771af627ed38d32c422 to your computer and use it in GitHub Desktop.
APT style progress bar
#!/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
@ssg
Copy link
Author

ssg commented Aug 31, 2023

I created this to reproduce the false ligatures problem with Berkeley Mono font and apt's progress bar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment