diff --git a/1.4.md b/1.4.md index 601f3fe7..19ae5bb5 100644 --- a/1.4.md +++ b/1.4.md @@ -8,6 +8,12 @@ ### 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
+will be drawn with. +- Added `--progress_colors` to color the progress bars. +- Added `$progress_color_elapsed` and `$progress_color_total` config options. + **Battery**
- Added support for NetBSD diff --git a/README.md b/README.md index 5e7c19c4..2308ac34 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,12 @@ alias fetch2="fetch \ --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 type Image source. Where and what image we display. Possible values: wall, shuffle, ascii, diff --git a/config/config b/config/config index 71b2f723..bd389ac3 100644 --- a/config/config +++ b/config/config @@ -215,6 +215,21 @@ underline_char="-" 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 {{{ diff --git a/neofetch b/neofetch index eff8fe14..29aa81ef 100755 --- a/neofetch +++ b/neofetch @@ -235,6 +235,21 @@ underline_char="-" 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 {{{ @@ -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 + 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 type Image source. Where and what image we display. Possible values: wall, shuffle, ascii, @@ -2397,6 +2437,13 @@ while [ "$1" ]; do --block_range) start=$2; end=$3 ;; --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="$2"