Add config options

`@catppuccin_window_left_separator_inverse`
`@catppuccin_window_right_separator_inverse`
`@catppuccin_status_left_separator_inverse`
This commit is contained in:
ervinpopescu 2023-09-09 16:28:50 +03:00
parent 79230ddb54
commit bb129ad37a
No known key found for this signature in database

View file

@ -7,10 +7,8 @@ get_tmux_option() {
default="$2" default="$2"
value=$(tmux show-option -gqv "$option") value=$(tmux show-option -gqv "$option")
if [ -n "$value" ] if [ -n "$value" ]; then
then if [ "$value" = "null" ]; then
if [ "$value" = "null" ]
then
echo "" echo ""
else else
@ -46,14 +44,12 @@ build_window_icon() {
local custom_icon_window_activity=$(get_tmux_option "@catppuccin_icon_window_activity" "󰖲") local custom_icon_window_activity=$(get_tmux_option "@catppuccin_icon_window_activity" "󰖲")
local custom_icon_window_bell=$(get_tmux_option "@catppuccin_icon_window_bell" "󰂞") local custom_icon_window_bell=$(get_tmux_option "@catppuccin_icon_window_bell" "󰂞")
if [ "$window_status_icon_enable" = "yes" ] if [ "$window_status_icon_enable" = "yes" ]; then
then
# #!~[*-]MZ # #!~[*-]MZ
local show_window_status="#{?window_activity_flag,${custom_icon_window_activity},}#{?window_bell_flag,${custom_icon_window_bell},}#{?window_silence_flag,${custom_icon_window_silent},}#{?window_active,${custom_icon_window_current},}#{?window_last_flag,${custom_icon_window_last},}#{?window_marked_flag,${custom_icon_window_mark},}#{?window_zoomed_flag,${custom_icon_window_zoom},}" local show_window_status="#{?window_activity_flag,${custom_icon_window_activity},}#{?window_bell_flag,${custom_icon_window_bell},}#{?window_silence_flag,${custom_icon_window_silent},}#{?window_active,${custom_icon_window_current},}#{?window_last_flag,${custom_icon_window_last},}#{?window_marked_flag,${custom_icon_window_mark},}#{?window_zoomed_flag,${custom_icon_window_zoom},}"
fi fi
if [ "$window_status_icon_enable" = "no" ] if [ "$window_status_icon_enable" = "no" ]; then
then
local show_window_status="#F" local show_window_status="#F"
fi fi
@ -67,14 +63,12 @@ build_window_format() {
local text=$4 local text=$4
local fill=$5 local fill=$5
if [ "$window_status_enable" = "yes" ] if [ "$window_status_enable" = "yes" ]; then
then local icon="$(build_window_icon)"
local icon="$( build_window_icon )"
text="$text $icon" text="$text $icon"
fi fi
if [ "$fill" = "none" ] if [ "$fill" = "none" ]; then
then
local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_number="#[fg=$thm_fg,bg=$thm_gray]$number" local show_number="#[fg=$thm_fg,bg=$thm_gray]$number"
local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator" local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator"
@ -83,8 +77,7 @@ build_window_format() {
fi fi
if [ "$fill" = "all" ] if [ "$fill" = "all" ]; then
then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_number="#[fg=$background,bg=$color]$number" local show_number="#[fg=$background,bg=$color]$number"
local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$window_middle_separator" local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$window_middle_separator"
@ -93,35 +86,52 @@ build_window_format() {
fi fi
if [ "$fill" = "number" ] if [ "$fill" = "number" ]; then
then
local show_number="#[fg=$background,bg=$color]$number" local show_number="#[fg=$background,bg=$color]$number"
local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$window_middle_separator" local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$window_middle_separator"
local show_text="#[fg=$thm_fg,bg=$background]$text" local show_text="#[fg=$thm_fg,bg=$background]$text"
if [ "$window_number_position" = "right" ] if [ "$window_number_position" = "right" ]; then
then
local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator" local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"
fi fi
if [ "$window_number_position" = "left" ] if [ "$window_number_position" = "left" ]; then
then
local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator" local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator"
local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator" local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator"
fi fi
fi fi
if [ "$window_left_separator_inverse" = "yes" ]; then
local show_left_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$window_left_separator"
fi
if [ "$window_right_separator_inverse" = "yes" ]; then
local show_right_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$window_right_separator"
fi
if [ $((index)) -eq 0 ]; then
if [ "$window_left_separator_inverse" = "yes" ]; then
local show_left_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$window_left_separator"
else
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
fi
if [ "$window_right_separator_inverse" = "yes" ]; then
local show_right_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$window_right_separator"
else
local show_right_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator"
fi
fi
local final_window_format local final_window_format
if [ "$window_number_position" = "right" ] if [ "$window_number_position" = "right" ]; then
then
final_window_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator" final_window_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator"
fi fi
if [ "$window_number_position" = "left" ] if [ "$window_number_position" = "left" ]; then
then
final_window_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator" final_window_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator"
fi fi
@ -134,8 +144,7 @@ build_status_module() {
local color=$3 local color=$3
local text=$4 local text=$4
if [ "$status_fill" = "icon" ] if [ "$status_fill" = "icon" ]; then
then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"
local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon " local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
@ -143,8 +152,7 @@ build_status_module() {
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator"
if [ "$status_connect_separator" = "yes" ] if [ "$status_connect_separator" = "yes" ]; then
then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator" local show_right_separator="#[fg=$thm_gray,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator"
@ -155,8 +163,7 @@ build_status_module() {
fi fi
if [ "$status_fill" = "all" ] if [ "$status_fill" = "all" ]; then
then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"
local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon " local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
@ -164,8 +171,7 @@ build_status_module() {
local show_right_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator" local show_right_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator"
if [ "$status_connect_separator" = "yes" ] if [ "$status_connect_separator" = "yes" ]; then
then
local show_left_separator="#[fg=$color,nobold,nounderscore,noitalics]$status_left_separator" local show_left_separator="#[fg=$color,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$color,bg=$color,nobold,nounderscore,noitalics]$status_right_separator" local show_right_separator="#[fg=$color,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
@ -176,21 +182,29 @@ build_status_module() {
fi fi
if [ "$status_right_separator_inverse" = "yes" ] if [ "$status_left_separator_inverse" = "yes" ]; then
then if [ "$status_connect_separator" = "yes" ]; then
if [ "$status_connect_separator" = "yes" ] local show_left_separator="#[fg=$thm_gray,bg=$color,nobold,nounderscore,noitalics]$status_left_separator"
then else
local show_left_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$status_left_separator"
fi
fi
if [ "$status_right_separator_inverse" = "yes" ]; then
if [ "$status_connect_separator" = "yes" ]; then
local show_right_separator="#[fg=$thm_gray,bg=$color,nobold,nounderscore,noitalics]$status_right_separator" local show_right_separator="#[fg=$thm_gray,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
else else
local show_right_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$status_right_separator" local show_right_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
fi fi
fi fi
if [ $(($index)) -eq 0 ] if [ $((index)) -eq 0 ]; then
then if [ "$status_left_separator_inverse" = "yes" ]; then
local show_left_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$status_left_separator"
else
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
fi
fi fi
echo "$show_left_separator$show_icon$show_text$show_right_separator" echo "$show_left_separator$show_icon$show_text$show_right_separator"
} }
@ -201,13 +215,13 @@ load_modules() {
local modules_status_path=$PLUGIN_DIR/status local modules_status_path=$PLUGIN_DIR/status
local modules_window_path=$PLUGIN_DIR/window local modules_window_path=$PLUGIN_DIR/window
local module_index=0; local module_index=0
local module_name local module_name
local loaded_modules local loaded_modules
local IN=$modules_list local IN=$modules_list
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash#15988793 # https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash#15988793
while [ "$IN" != "$iter" ] ;do while [ "$IN" != "$iter" ]; do
# extract the substring from start of string up to delimiter. # extract the substring from start of string up to delimiter.
iter=${IN%% *} iter=${IN%% *}
# delete this first "element" AND next separator, from $IN. # delete this first "element" AND next separator, from $IN.
@ -219,9 +233,8 @@ load_modules() {
local module_path=$modules_custom_path/$module_name.sh local module_path=$modules_custom_path/$module_name.sh
source $module_path source $module_path
if [ 0 -eq $? ] if [ 0 -eq $? ]; then
then loaded_modules="$loaded_modules$(show_$module_name $module_index)"
loaded_modules="$loaded_modules$( show_$module_name $module_index )"
module_index=$module_index+1 module_index=$module_index+1
continue continue
fi fi
@ -229,9 +242,8 @@ load_modules() {
local module_path=$modules_status_path/$module_name.sh local module_path=$modules_status_path/$module_name.sh
source $module_path source $module_path
if [ 0 -eq $? ] if [ 0 -eq $? ]; then
then loaded_modules="$loaded_modules$(show_$module_name $module_index)"
loaded_modules="$loaded_modules$( show_$module_name $module_index )"
module_index=$module_index+1 module_index=$module_index+1
continue continue
fi fi
@ -239,9 +251,8 @@ load_modules() {
local module_path=$modules_window_path/$module_name.sh local module_path=$modules_window_path/$module_name.sh
source $module_path source $module_path
if [ 0 -eq $? ] if [ 0 -eq $? ]; then
then loaded_modules="$loaded_modules$(show_$module_name $module_index)"
loaded_modules="$loaded_modules$( show_$module_name $module_index )"
module_index=$module_index+1 module_index=$module_index+1
continue continue
fi fi
@ -263,14 +274,14 @@ main() {
# shellcheck source=catppuccin-frappe.tmuxtheme # shellcheck source=catppuccin-frappe.tmuxtheme
# https://github.com/dylanaraps/pure-sh-bible#parsing-a-keyval-file # https://github.com/dylanaraps/pure-sh-bible#parsing-a-keyval-file
while IFS='=' read -r key val; do while IFS='=' read -r key val; do
# Skip over lines containing comments. # Skip over lines containing comments.
# (Lines starting with '#'). # (Lines starting with '#').
[ "${key##\#*}" ] || continue [ "${key##\#*}" ] || continue
# '$key' stores the key. # '$key' stores the key.
# '$val' stores the value. # '$val' stores the value.
eval "local $key"="$val" eval "local $key"="$val"
done < "${PLUGIN_DIR}/catppuccin-${theme}.tmuxtheme" done <"${PLUGIN_DIR}/catppuccin-${theme}.tmuxtheme"
# status # status
set status "on" set status "on"
@ -295,28 +306,31 @@ main() {
# --------=== Statusline # --------=== Statusline
local window_left_separator=$(get_tmux_option "@catppuccin_window_left_separator" "█") local window_left_separator=$(get_tmux_option "@catppuccin_window_left_separator" "█")
local window_left_separator_inverse=$(get_tmux_option "@catppuccin_window_left_separator_inverse" "no")
local window_right_separator=$(get_tmux_option "@catppuccin_window_right_separator" "█") local window_right_separator=$(get_tmux_option "@catppuccin_window_right_separator" "█")
local window_right_separator_inverse=$(get_tmux_option "@catppuccin_window_right_separator_inverse" "no")
local window_middle_separator=$(get_tmux_option "@catppuccin_window_middle_separator" "█ ") local window_middle_separator=$(get_tmux_option "@catppuccin_window_middle_separator" "█ ")
local window_number_position=$(get_tmux_option "@catppuccin_window_number_position" "left") # right, left local window_number_position=$(get_tmux_option "@catppuccin_window_number_position" "left") # right, left
local window_status_enable=$(get_tmux_option "@catppuccin_window_status_enable" "no") # right, left local window_status_enable=$(get_tmux_option "@catppuccin_window_status_enable" "no") # right, left
local window_format=$( load_modules "window_default_format") local window_format=$(load_modules "window_default_format")
local window_current_format=$( load_modules "window_current_format") local window_current_format=$(load_modules "window_current_format")
setw window-status-format "$window_format" setw window-status-format "$window_format"
setw window-status-current-format "$window_current_format" setw window-status-current-format "$window_current_format"
local status_left_separator=$(get_tmux_option "@catppuccin_status_left_separator" "") local status_left_separator=$(get_tmux_option "@catppuccin_status_left_separator" "")
local status_left_separator_inverse=$(get_tmux_option "@catppuccin_status_left_separator_inverse" "no")
local status_right_separator=$(get_tmux_option "@catppuccin_status_right_separator" "█") local status_right_separator=$(get_tmux_option "@catppuccin_status_right_separator" "█")
local status_right_separator_inverse=$(get_tmux_option "@catppuccin_status_right_separator_inverse" "no") local status_right_separator_inverse=$(get_tmux_option "@catppuccin_status_right_separator_inverse" "no")
local status_connect_separator=$(get_tmux_option "@catppuccin_status_connect_separator" "yes") local status_connect_separator=$(get_tmux_option "@catppuccin_status_connect_separator" "yes")
local status_fill=$(get_tmux_option "@catppuccin_status_fill" "icon") local status_fill=$(get_tmux_option "@catppuccin_status_fill" "icon")
local status_modules_right=$(get_tmux_option "@catppuccin_status_modules_right" "application session") local status_modules_right=$(get_tmux_option "@catppuccin_status_modules_right" "application session")
local loaded_modules_right=$( load_modules "$status_modules_right") local loaded_modules_right=$(load_modules "$status_modules_right")
local status_modules_left=$(get_tmux_option "@catppuccin_status_modules_left" "") local status_modules_left=$(get_tmux_option "@catppuccin_status_modules_left" "")
local loaded_modules_left=$( load_modules "$status_modules_left") local loaded_modules_left=$(load_modules "$status_modules_left")
set status-left "$loaded_modules_left" set status-left "$loaded_modules_left"
set status-right "$loaded_modules_right" set status-right "$loaded_modules_right"