1
0
Fork 0
mirror of synced 2025-01-07 05:52:14 -05:00

added the gradient(colour_fg_1,coulour_fg_2,...,colour_fg_n) bar palette style

note that there's no interpolation being performed between color values
This commit is contained in:
Gregory Pakosz 2024-12-31 10:47:10 +01:00
parent 065da52c67
commit 34d654f917
2 changed files with 109 additions and 53 deletions

View file

@ -1,4 +1,6 @@
# : << 'EOF'
# Oh my tmux!
# 💛🩷💙🖤❤️🤍
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
@ -308,8 +310,8 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# bar_palette=$(printf '%s' "$1" | tr ';' ',')
# bar_symbol_empty=$2
# bar_symbol_full=$3
# bar_length=$4
# bar_value=$5
# bar_length=$4 # "auto" or number of columns
# bar_value=$5 # value between 0 and 1
#
# if [ "$bar_length" = "auto" ]; then
# columns=${6:-$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)}
@ -326,48 +328,62 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# fi
# fi
#
# if echo "$bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# if printf '%s' "$bar_palette" | grep -q -E '^(heat|gradient|gradient\((\s*[#a-zA-Z0-9]{7,9},?)+\))(\s*,\s*[#a-zA-Z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $bar_palette; unset IFS; set +f; }
# { set -f; IFS=', '; set -- $bar_palette; unset IFS; set +f; }
# palette_style=$1
# bg=${2:-none}
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="243 245 247 144 143 142 184 214 208 202 196"
# shift
#
# palette=$(echo "$palette" | awk -v n="$bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
# case "$palette_style" in
# gradient)
# palette="colour196 colour202 colour208 colour214 colour220 colour226 colour190 colour154 colour118 colour82 colour46"
# ;;
# heat)
# palette="colour243 colour245 colour247 colour144 colour143 colour142 colour184 colour214 colour208 colour202 colour196"
# ;;
# gradient*)
# palette=${palette_style##gradient(}
# while [ $# -gt 0 ]; do
# palette="$palette${1+ }${1%%)}"
# [ "$1" != "${1%%)}" ] && break
# shift
# done
# ;;
# esac
# bg=${2:-none}
#
# palette=$(printf '%s' "$palette" | awk -v n="$bar_length" '{ for (i = 0; i < n - 1; ++i) printf "%s ", $(1 + i * NF / n); printf $NF }')
# # shellcheck disable=SC2086
# set -- $palette
#
# full=$(awk "BEGIN { printf \"%.0f\", ($bar_value) * $bar_length }")
# bar="#[bg=$bg]"
# # shellcheck disable=SC2046
# [ "$full" -gt 0 ] && \
# bar="$bar$(printf "#[fg=colour%s]$bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))"
# # shellcheck disable=SC2046
# if [ "$full" -gt 0 ]; then
# # shellcheck disable=SC2046
# bar="$bar$(printf "#[fg=%s]$bar_symbol_full" $(printf '%s' "$palette" | cut -d' ' -f1-"$full"))"
# fi
# empty=$((bar_length - full))
# # shellcheck disable=SC2046
# [ "$empty" -gt 0 ] && \
# bar="$bar$(printf "#[fg=colour%s]$bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
# eval bar="$bar#[fg=colour\${$((full == 0 ? 1 : full))}]"
# elif echo "$bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then
# if [ "$empty" -gt 0 ]; then
# # shellcheck disable=SC2046
# bar="$bar$(printf "#[fg=%s]$bar_symbol_empty" $(printf '%s' "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
# fi
# eval bar="$bar#[fg=\${$((full == 0 ? 1 : full))}]"
# elif printf '%s' "$bar_palette" | grep -q -E '^(([#a-zA-Z0-9]{7,9}|none),?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $bar_palette; unset IFS; set +f; }
# full_fg=$1
# empty_fg=$2
# bg=$3
# bg=${3:-none}
#
# full=$(awk "BEGIN { printf \"%.0f\", ($bar_value) * $bar_length }")
# [ "$bg" != "none" ] && \
# bar="#[bg=$bg]"
# #shellcheck disable=SC2046
# [ "$full" -gt 0 ] && \
# bar="#[bg=$bg]"
# if [ "$full" -gt 0 ]; then
# bar="$bar#[fg=$full_fg]$(printf "%0.s$bar_symbol_full" $(seq 1 "$full"))"
# fi
# empty=$((bar_length - full))
# #shellcheck disable=SC2046
# [ "$empty" -gt 0 ] && \
# bar="$bar#[fg=$empty_fg]$(printf "%0.s$bar_symbol_empty" $(seq 1 "$empty"))" && \
# bar="$bar#[fg=$empty_fg]"
# if [ "$empty" -gt 0 ]; then
# bar="$bar#[fg=$empty_fg]$(printf "%0.s$bar_symbol_empty" $(seq 1 "$empty"))#[fg=$empty_fg]"
# fi
# fi
#
# printf '%s' "$bar"
@ -377,21 +393,37 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# hbar_palette=$(printf '%s' "$1" | tr ';' ',')
# hbar_value=$2
#
# if echo "$hbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# if printf '%s' "$hbar_palette" | grep -q -E '^(heat|gradient|gradient\((\s*[#a-zA-Z0-9]{7,9},?)+\))(\s*,\s*[#a-zA-Z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $hbar_palette; unset IFS; set +f; }
# { set -f; IFS=', '; set -- $hbar_palette; unset IFS; set +f; }
# palette_style=$1
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
# shift
#
# palette=$(echo "$palette" | awk -v n=8 '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
# case "$palette_style" in
# gradient)
# palette="colour196 colour202 colour208 colour214 colour220 colour226 colour190 colour154 colour118 colour82 colour46"
# ;;
# heat)
# palette="colour243 colour245 colour247 colour144 colour143 colour142 colour184 colour214 colour208 colour202 colour196"
# ;;
# gradient*)
# palette=${palette_style##gradient(}
# while [ $# -gt 0 ]; do
# palette="$palette${1+ }${1%%)}"
# [ "$1" != "${1%%)}" ] && break
# shift
# done
# ;;
# esac
# bg=${2:-none}
#
# palette=$(printf '%s' "$palette" | awk -v n=8 '{ for (i = 0; i < n - 1; ++i) printf "%s ", $(1 + i * NF / n); printf $NF }')
# # shellcheck disable=SC2086
# set -- $palette
#
# full=$(awk "BEGIN { printf \"%.0f\", ($hbar_value) * 8 }")
# eval hbar_fg="colour\${$((full == 0 ? 1 : full))}"
# elif echo "$hbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
# eval hbar_fg="\${$((full == 0 ? 1 : full))}"
# elif printf '%s' "$hbar_palette" | grep -q -E '^([#a-zA-Z0-9]{7,9},?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $hbar_palette; unset IFS; set +f; }
#
@ -399,10 +431,10 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# eval $(awk "BEGIN { printf \"hbar_fg=$%d\", (($hbar_value) - 0.001) * $# + 1 }")
# fi
#
# eval set -- "▏ ▎ ▍ ▌ ▋ ▊ ▉ █"
# set -- ▏ ▎ ▍ ▌ ▋ ▊ ▉ █
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"hbar_symbol=$%d\", ($hbar_value) * ($# - 1) + 1 }")
# hbar="#[bg=none]#[fg=${hbar_fg?}]${hbar_symbol?}"
# hbar="#[bg=$bg]#[fg=${hbar_fg?}]${hbar_symbol?}"
#
# printf '%s' "$hbar"
# }
@ -411,21 +443,37 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# vbar_palette=$(printf '%s' "$1" | tr ';' ',')
# vbar_value=$2
#
# if echo "$vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# if printf '%s' "$vbar_palette" | grep -q -E '^(heat|gradient|gradient\((\s*[#a-zA-Z0-9]{7,9},?)+\))(\s*,\s*[#a-zA-Z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $vbar_palette; unset IFS; set +f; }
# { set -f; IFS=', '; set -- $vbar_palette; unset IFS; set +f; }
# palette_style=$1
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
# shift
#
# palette=$(echo "$palette" | awk -v n=8 '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
# case "$palette_style" in
# gradient)
# palette="colour196 colour202 colour208 colour214 colour220 colour226 colour190 colour154 colour118 colour82 colour46"
# ;;
# heat)
# palette="colour243 colour245 colour247 colour144 colour143 colour142 colour184 colour214 colour208 colour202 colour196"
# ;;
# gradient*)
# palette=${palette_style##gradient(}
# while [ $# -gt 0 ]; do
# palette="$palette${1+ }${1%%)}"
# [ "$1" != "${1%%)}" ] && break
# shift
# done
# ;;
# esac
# bg=${2:-none}
#
# palette=$(printf '%s' "$palette" | awk -v n=8 '{ for (i = 0; i < n - 1; ++i) printf "%s ", $(1 + i * NF / n); printf $NF }')
# # shellcheck disable=SC2086
# set -- $palette
#
# full=$(awk "BEGIN { printf \"%.0f\", ($vbar_value) * 8 }")
# eval vbar_fg="colour\${$((full == 0 ? 1 : full))}"
# elif echo "$vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
# eval vbar_fg="\${$((full == 0 ? 1 : full))}"
# elif printf '%s' "$vbar_palette" | grep -q -E '^([#a-zA-Z0-9]{7,9},?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $vbar_palette; unset IFS; set +f; }
#
@ -433,10 +481,10 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# eval $(awk "BEGIN { printf \"vbar_fg=$%d\", (($vbar_value) - 0.001) * $# + 1 }")
# fi
#
# eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █"
# set -- ▁ ▂ ▃ ▄ ▅ ▆ ▇ █
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"vbar_symbol=$%d\", ($vbar_value) * ($# - 1) + 1 }")
# vbar="#[bg=none]#[fg=${vbar_fg?}]${vbar_symbol?}"
# vbar="#[bg=$bg]#[fg=${vbar_fg?}]${vbar_symbol?}"
#
# printf '%s' "$vbar"
# }

View file

@ -1,4 +1,6 @@
# : << EOF
# Oh my tmux!
# 💛🩷💙🖤❤️🤍
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
@ -326,22 +328,28 @@ tmux_conf_battery_bar_length="auto"
# - gradient (default)
# - heat
# - "colour_full_fg,colour_empty_fg,colour_bg"
# - gradient(colour_fg_1,colour_fg_2,...,colour_fg_n)
tmux_conf_battery_bar_palette="gradient"
#tmux_conf_battery_bar_palette="#d70000,#e4e4e4,#000000" # red, white, black
#tmux_conf_battery_bar_palette="gradient(#00afff,#47a2ff,#7c91ff,#ac7afb,#d65be2,#e163df,#eb6cdd,#f475db,#ec9ff1,#eac3fe,#efe2ff,#ffffff)"
# battery hbar palette, possible values are:
# - gradient (default)
# - heat
# - "colour_low,colour_half,colour_full"
# - gradient(colour_fg_1,colour_fg_2,...,colour_fg_n)
tmux_conf_battery_hbar_palette="gradient"
#tmux_conf_battery_hbar_palette="#d70000,#ff5f00,#5fff00" # red, orange, green
#tmux_conf_battery_hbar_palette="gradient(#00afff,#47a2ff,#7c91ff,#ac7afb,#d65be2,#e163df,#eb6cdd,#f475db,#ec9ff1,#eac3fe,#efe2ff,#ffffff)"
# battery vbar palette, possible values are:
# - gradient (default)
# - heat
# - "colour_low,colour_half,colour_full"
# - gradient(colour_fg_1,colour_fg_2,...,colour_fg_n)
tmux_conf_battery_vbar_palette="gradient"
#tmux_conf_battery_vbar_palette="#d70000,#ff5f00,#5fff00" # red, orange, green
#tmux_conf_battery_vbar_palette="gradient(#00afff,#47a2ff,#7c91ff,#ac7afb,#d65be2,#e163df,#eb6cdd,#f475db,#ec9ff1,#eac3fe,#efe2ff,#ffffff)"
# symbols used to indicate whether battery is charging or discharging
tmux_conf_battery_status_charging="↑" # U+2191