Last active
December 17, 2015 02:48
-
-
Save WayneSan/5538108 to your computer and use it in GitHub Desktop.
Revisions
-
WayneSan revised this gist
May 8, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/bin/bash #### Preprocessing #### if [ "$1" == "--color" ]; then COLOR="TRUE"; shift; fi -
WayneSan renamed this gist
May 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
WayneSan created this gist
May 8, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/bin/sh #### Preprocessing #### if [ "$1" == "--color" ]; then COLOR="TRUE"; shift; fi if [ $# -lt 2 ]; then echo "Usage: $0 [--color] TITLE PROGRESS [MAXIMUM]" exit fi if [ $# -ge 3 ] && [ $3 -gt 0 ]; then MAX=$3; else MAX=100; fi PRG=$2 if [ $PRG -gt $MAX ]; then echo "Error: PROGRESS needs smaller than MAXIMUM." exit fi #### Main Program #### echo -en '\r' echo -n "$1: " LI=('\' '|' '/' '-') let MAXL=`echo $MAX | wc -m`-1 let COLS=`tput cols`-`echo $1 | wc -m`-$((MAXL * 2))-23 let PEC=(PRG*100)/MAX echo -n '[ ' PRGBAR=`printf '%*s' $((PEC * COLS / 100)) | tr ' ' '#'` [ "$COLOR" == "TRUE" ] && echo -en "\033[1;3$(($PRG % 8))m" printf "%-${COLS}.${COLS}s" "$PRGBAR${LI[$PRG % 4]}" [ "$COLOR" == "TRUE" ] && echo -en "\033[m" #echo -n " ] $PEC%" #echo -n " ($PRG/$MAX)... " printf " ] %3s%% (%${MAXL}s/%${MAXL}s)... " "$PEC" "$PRG" "$MAX" [ $PRG -ge $MAX ] && echo 'done.'