mkbar
mkbar is for printing configurable, colored, text-based progress bars to a console. Originally built for use with update-motd and tmux, but should work great for anything that renders numeric output from a shell command, like Übersicht or BitBar.
Colored output is from mitchellh/colorstring, and environment variable parsing from caarlos0/env.
$ go get github.com/travis-g/utils/mkbar
Usage
Either provide a 0-100 percentage value as $1 or pipe a value in:
$ mkbar 30
######--------------
$ pmset -g batt | grep -Eo "\d+%" | cut -d% -f1 | mkbar # my battery at time of writing
##############------
Configure it inline or with shell variables:
$ export SIZE=15 START="[" END="]"
$ CHAR1="━" SEP="╋" CHAR2="━" mkbar 50
[━━━━━━━╋━━━━━━━]
Note that SEP is the first character of the inactive portion of the bar.
If you're looking for conditional color formatting, try a wrapper script:
$ cat mkbar.sh
#!/usr/bin/env bash
[[ "$1" -le "20" ]] && export START="[red]⚠️ "
mkbar $1
$ ./mkbar.sh 50
##########----------
$ ./mkbar.sh 20
⚠️ ####----------------