mkbar

command
v0.0.0-...-55dc3e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 6 Imported by: 0

README

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
⚠️ ####----------------

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址