Added base support for progress bars

This commit is contained in:
Dylan 2016-03-03 10:12:21 +11:00
parent 0c165df09c
commit d142efe2db
4 changed files with 74 additions and 0 deletions

6
1.4.md
View file

@ -8,6 +8,12 @@
### Info ### Info
- Added the ability to print certain info as a progress bar.
- Added `--progress_char` and `$progress_char` to set the character the progress bars<br \>
will be drawn with.
- Added `--progress_colors` to color the progress bars.
- Added `$progress_color_elapsed` and `$progress_color_total` config options.
**Battery**<br \> **Battery**<br \>
- Added support for NetBSD - Added support for NetBSD

View file

@ -280,6 +280,12 @@ alias fetch2="fetch \
--block_range start end Range of colors to print as blocks --block_range start end Range of colors to print as blocks
Progress Bars:
--progress_char char Character to use when drawing progress bars.
--progress_colors num num Colors to make the progress bar. Set in this order:
elapsed, total
Image: Image:
--image type Image source. Where and what image we display. --image type Image source. Where and what image we display.
Possible values: wall, shuffle, ascii, Possible values: wall, shuffle, ascii,

View file

@ -215,6 +215,21 @@ underline_char="-"
prompt_height=1 prompt_height=1
# }}}
# Progress Bars {{{
# Progress bar character
# --progress_char char
progress_char="━"
# Progress bar colors
# --progress_colors col col
progress_color_elapsed="6"
progress_color_total="8"
# }}} # }}}
# Image Options {{{ # Image Options {{{

View file

@ -235,6 +235,21 @@ underline_char="-"
prompt_height=1 prompt_height=1
# }}}
# Progress Bars {{{
# Progress bar character
# --progress_char char
progress_char="━"
# Progress bar colors
# --progress_colors col col
progress_color_elapsed="6"
progress_color_total="8"
# }}} # }}}
# Image Options {{{ # Image Options {{{
@ -2227,6 +2242,25 @@ esac
# }}} # }}}
# Progress Bars {{{
bar() {
# Get the values
percent="$1"
length="$2"
inc=$((percent * length / 100))
# Create the bar with spaces
prog=$(printf %"$inc"s)
total=$(printf %"$((length - inc))"s)
# Set the colors and swap the spaces for $progress_char
bar="\033[38;5;${progress_color_elapsed}m${prog// /$progress_char}"
bar+="\033[38;5;${progress_color_total}m${total// /$progress_char}"
printf "%b%s\n" "${bar}${clear}"
}
# }}}
# }}} # }}}
@ -2284,6 +2318,12 @@ usage () { cat << EOF
--block_range start end Range of colors to print as blocks --block_range start end Range of colors to print as blocks
Progress Bars:
--progress_char char Character to use when drawing progress bars.
--progress_colors num num Colors to make the progress bar. Set in this order:
elapsed, total
Image: Image:
--image type Image source. Where and what image we display. --image type Image source. Where and what image we display.
Possible values: wall, shuffle, ascii, Possible values: wall, shuffle, ascii,
@ -2397,6 +2437,13 @@ while [ "$1" ]; do
--block_range) start=$2; end=$3 ;; --block_range) start=$2; end=$3 ;;
--block_width) block_width="$2" ;; --block_width) block_width="$2" ;;
# Progress Bars
--progress_char) progress_char="$2" ;;
--progress_colors)
progress_color_elapsed="$2"
progress_color_total="$3"
;;
# Image # Image
--image) --image)
image="$2" image="$2"