From 550185fa7ed993dbc693950e72a0c1c26e331092 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 24 Apr 2016 18:30:57 +1000 Subject: [PATCH] Made progress bars more customizable --- 1.7.md | 33 +++++++++++++++++++++++++++++++++ config/config | 9 +++++++-- neofetch | 26 +++++++++++++++++++++----- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/1.7.md b/1.7.md index 42f906ab..6b392afb 100644 --- a/1.7.md +++ b/1.7.md @@ -72,6 +72,7 @@ underline_enabled="on" - Added KDE neon ascii art. + ### Colors - Fixed bug with `--colors` not working with all 256 terminal colors. @@ -82,3 +83,35 @@ underline_enabled="on" would be white or black. This caused issues for those setting the foreground
color to red or etc. This change adds a new value for `--colors` and `colors=()`
called `fg` which will set the color to your foreground color. + + +### Progress Bars + +- You can now enable/disable a border around the progress bars. + +```sh +# $progress_border on +[=====-----] + +# $progress_border off +=====----- +``` + +- You can now individually set the progress bar characters. This means that you can
+have a seperate character for the elapsed and total portions of the bar. + +```sh +# Examples with $progress_border on + +# Elapsed: = +# Total: - +[=====-----] + +# Elapsed: . +# Total: " " +[..... ] + +# Elapsed: / +# Total: " " +[///// ] +``` diff --git a/config/config b/config/config index 63c17adf..6a3be279 100644 --- a/config/config +++ b/config/config @@ -250,8 +250,13 @@ prompt_height=1 # Progress bar character -# --progress_char char -progress_char="━" +# --progress_char elapsed_char total_char +progress_char_elapsed="-" +progress_char_total="=" + +# Progress vorder +# --progress_border on/off +progress_border="on" # Progress bar length in spaces # Number of chars long to make the progress bars. diff --git a/neofetch b/neofetch index 0f7fdb76..4064a300 100755 --- a/neofetch +++ b/neofetch @@ -275,8 +275,13 @@ prompt_height=1 # Progress bar character -# --progress_char char -progress_char="━" +# --progress_char elapsed_char total_char +progress_char_elapsed="=" +progress_char_total="-" + +# Progress vorder +# --progress_border on/off +progress_border="on" # Progress bar length in spaces # Number of chars long to make the progress bars. @@ -2547,8 +2552,15 @@ bar() { total=$(printf %"$((progress_length - elapsed))"s) # Set the colors and swap the spaces for $progress_char - bar="${progress_color_elapsed}${prog// /$progress_char}" - bar+="${progress_color_total}${total// /$progress_char}" + bar+="${progress_color_elapsed}${prog// /$progress_char_elapsed}" + bar+="${progress_color_total}${total// /$progress_char_total}" + + # Borders + if [ "$progress_border" == "on" ]; then + bar+="$(color fg)]" + bar="$(color fg)[$bar" + fi + printf "%b%s\n" "${bar}${clear}" } @@ -2779,7 +2791,11 @@ while [ "$1" ]; do --block_width) block_width="$2" ;; # Progress Bars - --progress_char) progress_char="$2" ;; + --progress_char) + progress_char_elapsed="$2" + progress_char_total="$3" + ;; + --progress_border) progress_border="$2" ;; --progress_length) progress_length="$2" ;; --progress_colors) progress_color_elapsed="$2"