From 7f2f83039bc5e4c781f653553f05a4cabf944224 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 09:53:35 +1000 Subject: [PATCH] Add '--block_height' / '$block_height' to change the height of the color blocks --- README.md | 3 ++- config/config | 39 ++++++++++++++++++------------ neofetch | 67 +++++++++++++++++++++++++++++++++------------------ neofetch.1 | 5 +++- 4 files changed, 73 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 2ea4aabb..5aef3a52 100644 --- a/README.md +++ b/README.md @@ -395,7 +395,8 @@ alias fetch2="fetch \ Color Blocks: --color_blocks on/off Enable/Disable the color blocks - --block_width num Width of color blocks + --block_width num Width of color blocks in spaces + --block_height num Height of color blocks in lines --block_range start end Range of colors to print as blocks diff --git a/config/config b/config/config index 5f77e057..3cdea9c8 100644 --- a/config/config +++ b/config/config @@ -185,22 +185,6 @@ birthday_time="on" birthday_format="+%a %d %b %Y %l:%M %p" -# Color Blocks - -# Color block range -# --block_range start end -start=0 -end=7 - -# Toggle color blocks -# --color_blocks on/off -color_blocks="on" - -# Color block width -# --color_block_width num -block_width=3 - - # }}} # Text Colors {{{ @@ -244,6 +228,29 @@ underline_char="-" prompt_height=1 +# }}} + +# Color Blocks {{{ + + +# Color block range +# --block_range start end +start=0 +end=7 + +# Toggle color blocks +# --color_blocks on/off +color_blocks="on" + +# Color block width in spaces +# --block_width num +block_width=3 + +# Color block height in lines +# --block_height num +block_height=1 + + # }}} # Progress Bars {{{ diff --git a/neofetch b/neofetch index 109d59cc..9be2f46f 100755 --- a/neofetch +++ b/neofetch @@ -210,22 +210,6 @@ birthday_time="on" birthday_format="%a %d %b %Y %l:%M %p" -# Color Blocks - -# Color block range -# --block_range start end -start=0 -end=7 - -# Toggle color blocks -# --color_blocks on/off -color_blocks="on" - -# Color block width -# --color_block_width num -block_width=3 - - # }}} # Text Colors {{{ @@ -269,6 +253,29 @@ underline_char="-" prompt_height=1 +# }}} + +# Color Blocks {{{ + + +# Color block range +# --block_range start end +start=0 +end=7 + +# Toggle color blocks +# --color_blocks on/off +color_blocks="on" + +# Color block width in spaces +# --block_width num +block_width=3 + +# Color block height in lines +# --block_height num +block_height=1 + + # }}} # Progress Bars {{{ @@ -1999,18 +2006,30 @@ getbirthday () { getcols () { if [ "$color_blocks" == "on" ]; then - printf "${padding}%s" + # Convert the width to space chars. + block_width=$(printf "%$((block_width-=1))s") + + # Generate the string. while [ $start -le $end ]; do case "$start" in - [0-6]) printf "\033[4${start}m%${block_width}s" ;; - 7) printf "\033[4${start}m%${block_width}s${clear}\n${padding}" ;; - *) printf "\033[48;5;${start}m%${block_width}s" ;; + [0-6]) blocks+="\033[0m\033[3${start}m\033[4${start}m%${block_width}s" ;; + 7) blocks+="\033[0m\033[3${start}m\033[4${start}m%${block_width}s" ;; + *) blocks2+="\033[38;5;${start}m\033[48;5;${start}m%${block_width}s" ;; esac start=$((start+=1)) done - # Clear formatting - printf "%b%s" "$clear" + # Add padding and newline to the end of the blocks. + blocks+="${clear}\n${padding}" + blocks2+="${clear}\n${padding}" + + # Convert height into spaces. + cols="$(printf "%${block_height}s")" + cols2="$(printf "%${block_height}s")" + + # Print the blocks. + cols=${cols// /${blocks}} + cols+=${cols2// /${blocks2}} fi } @@ -2867,7 +2886,8 @@ usage () { cat << EOF Color Blocks: --color_blocks on/off Enable/Disable the color blocks - --block_width num Width of color blocks + --block_width num Width of color blocks in spaces + --block_height num Height of color blocks in lines --block_range start end Range of colors to print as blocks @@ -3012,6 +3032,7 @@ while [ "$1" ]; do --color_blocks) color_blocks="$2" ;; --block_range) start=$2; end=$3 ;; --block_width) block_width="$2" ;; + --block_height) block_height="$2" ;; # Progress Bars --progress_char) diff --git a/neofetch.1 b/neofetch.1 index 0e633fd7..cc0f9a6a 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -121,7 +121,10 @@ with the text going off screen at the top Enable/Disable the color blocks .TP .B \--block_width 'num' -Width of color blocks +Width of color blocks in spaces +.TP +.B \--block_height 'num' +Height of color blocks in lines .TP .B \--block_range 'start' 'end' Range of colors to print as blocks