scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit 63a1cc075d5d90cb85cb24a3e3b1a388249e0735
parent 731b5e3228472879eca9f5ae881686d7c46640b5
Author: z3bra <willy@mailoo.org>
Date:   Wed Jan 14 20:11:03 +0100

Bar maker, for real

Diffstat:
mkb | 31+++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+), 0 deletions(-)
diff --git a/mkb b/mkb @@ -0,0 +1,31 @@ +#!/bin/sh +# +# z3bra - 2015 (c) wtfpl +# create a nice bar from a percentage + +SIZE=${SIZE:-28} + +CHAR1=${CHAR1:-▣} +CHAR2=${CHAR2:-▣} + +usage() { + echo "usage: $(basename $0) [perc]" >&2 + exit 1 +} + +test -n "$1" && IN=$1 || read IN + +# test the argument given +test $IN -ge 0 || usage +test $IN -le 100 || usage + +BAR= +VAL=$(( IN * SIZE / 100 )) + +for v in `seq 0 $(( SIZE - 1 ))`; do + test "$v" -le "$VAL" \ + && BAR="${BAR}${CHAR1}" \ + || BAR="${BAR}${CHAR2}" +done + +printf "%s\n" "$BAR"