Add '--block_height' / '$block_height' to change the height of the color blocks

This commit is contained in:
Dylan Araps 2016-05-28 09:53:35 +10:00
parent b1b71bff43
commit 7f2f83039b
4 changed files with 73 additions and 41 deletions

View File

@ -395,7 +395,8 @@ alias fetch2="fetch \
Color Blocks: Color Blocks:
--color_blocks on/off Enable/Disable the 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 --block_range start end Range of colors to print as blocks

View File

@ -185,22 +185,6 @@ birthday_time="on"
birthday_format="+%a %d %b %Y %l:%M %p" 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 {{{ # Text Colors {{{
@ -244,6 +228,29 @@ underline_char="-"
prompt_height=1 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 {{{ # Progress Bars {{{

View File

@ -210,22 +210,6 @@ birthday_time="on"
birthday_format="%a %d %b %Y %l:%M %p" 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 {{{ # Text Colors {{{
@ -269,6 +253,29 @@ underline_char="-"
prompt_height=1 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 {{{ # Progress Bars {{{
@ -1999,18 +2006,30 @@ getbirthday () {
getcols () { getcols () {
if [ "$color_blocks" == "on" ]; then 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 while [ $start -le $end ]; do
case "$start" in case "$start" in
[0-6]) printf "\033[4${start}m%${block_width}s" ;; [0-6]) blocks+="\033[0m\033[3${start}m\033[4${start}m%${block_width}s" ;;
7) printf "\033[4${start}m%${block_width}s${clear}\n${padding}" ;; 7) blocks+="\033[0m\033[3${start}m\033[4${start}m%${block_width}s" ;;
*) printf "\033[48;5;${start}m%${block_width}s" ;; *) blocks2+="\033[38;5;${start}m\033[48;5;${start}m%${block_width}s" ;;
esac esac
start=$((start+=1)) start=$((start+=1))
done done
# Clear formatting # Add padding and newline to the end of the blocks.
printf "%b%s" "$clear" 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 fi
} }
@ -2867,7 +2886,8 @@ usage () { cat << EOF
Color Blocks: Color Blocks:
--color_blocks on/off Enable/Disable the 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 --block_range start end Range of colors to print as blocks
@ -3012,6 +3032,7 @@ while [ "$1" ]; do
--color_blocks) color_blocks="$2" ;; --color_blocks) color_blocks="$2" ;;
--block_range) start=$2; end=$3 ;; --block_range) start=$2; end=$3 ;;
--block_width) block_width="$2" ;; --block_width) block_width="$2" ;;
--block_height) block_height="$2" ;;
# Progress Bars # Progress Bars
--progress_char) --progress_char)

View File

@ -121,7 +121,10 @@ with the text going off screen at the top
Enable/Disable the color blocks Enable/Disable the color blocks
.TP .TP
.B \--block_width 'num' .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 .TP
.B \--block_range 'start' 'end' .B \--block_range 'start' 'end'
Range of colors to print as blocks Range of colors to print as blocks