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.