Perc2
23. 6. 2019An attempt to do a script that would show percentage bar with 1/8 of single char resolution, using some unicode block chars
#U+2588 █ Full block 100 %
#U+2589 ▉ Left seven eighths block 87.5 %
#U+258A ▊ Left three quarters block 75 %
#U+258B ▋ Left five eighths block 62.5 %
#U+258C ▌ Left half block 50 %
#U+258D ▍ Left three eighths block 37.5 %
#U+258E ▎ Left one quarter block 25 %
#U+258F ▏ Left one eighth block 12.5 %
For a usage and tests see the beginning of the script.
Example output
for i in $(seq 0 0.1 100) ; do echo -ne "$i\t"; perc2 $i 100; done
27.0 ███████████████████████████
27.1 ███████████████████████████▏
27.2 ███████████████████████████▎
27.3 ███████████████████████████▎
27.4 ███████████████████████████▍
27.5 ███████████████████████████▌
27.6 ███████████████████████████▋
27.7 ███████████████████████████▊
27.8 ███████████████████████████▊
27.9 ████████████████████████████
28.0 ████████████████████████████
28.1 ████████████████████████████▏
28.2 ████████████████████████████▎
28.3 ████████████████████████████▎
28.4 ████████████████████████████▍
Usage examples
perc2 90 10
# int or float, int
should give 90 percent over the range of 10 chars (10 chars is 100%).
perc2 10
should give 10 percent over the range of terminal width (tput cols).
Enabling info (info=”1”) in script should give you some basic debug info, like so
perc2 12
█████████████████▋full=17 perc=62.5 asci=▋
where full is fullchars, perc is last block in percentage and asci is the closest representation of that percentage.