@@ -32,9 +32,8 @@ tmux_option() {
3232 fi
3333}
3434
35- escape_symbols () {
36- local -r string=" $1 "
37- echo " $string " | sed -e ' s/,/#,/g' -e ' s/}/#}/g'
35+ format_style () {
36+ echo " #[${1} ]" | sed -e ' s/,/]#[/g'
3837}
3938
4039# Defaults
@@ -48,50 +47,6 @@ default_copy_prompt='Copy'
4847default_sync_prompt=' Sync'
4948default_empty_prompt=' '
5049
51- highlight () {
52- local -r \
53- status=" $1 " \
54- prefix=" $( escape_symbols " $2 " ) " \
55- prefix_highlight=" $( escape_symbols " $3 " ) " \
56- show_copy_mode=" $4 " \
57- show_sync_mode=" $5 " \
58- copy_highlight=" $( escape_symbols " $6 " ) " \
59- sync_highlight=" $( escape_symbols " $7 " ) " \
60- output_prefix=" $( escape_symbols " $8 " ) " \
61- output_suffix=" $( escape_symbols " $9 " ) " \
62- copy=" $( escape_symbols " ${10} " ) " \
63- sync=" $( escape_symbols " ${11} " ) " \
64- empty=" $( escape_symbols " ${12} " ) "
65-
66- local -r status_value=" $( tmux_option " $status " ) "
67- local -r prefix_with_optional_affixes=" $prefix_highlight$output_prefix$prefix$output_suffix "
68- local -r copy_with_optional_affixes=" $copy_highlight$output_prefix$copy$output_suffix "
69- local -r sync_with_optional_affixes=" $sync_highlight$output_prefix$sync$output_suffix "
70-
71- if [[ " on" = " $empty_has_affixes " ]]; then
72- local -r empty_with_optional_affixes=" $empty_highlight$output_prefix$empty$output_suffix "
73- else
74- local -r empty_with_optional_affixes=" $empty_highlight$empty "
75- fi
76-
77- if [[ " on" = " $show_copy_mode " ]]; then
78- if [[ " on" = " $show_sync_mode " ]]; then
79- local -r fallback=" #{?pane_in_mode,$copy_with_optional_affixes ,#{?synchronize-panes,$sync_with_optional_affixes ,$empty_with_optional_affixes }}"
80- else
81- local -r fallback=" #{?pane_in_mode,$copy_with_optional_affixes ,$empty_with_optional_affixes }"
82- fi
83- else
84- if [[ " on" = " $show_sync_mode " ]]; then
85- local -r fallback=" #{?synchronize-panes,$sync_with_optional_affixes ,$empty_with_optional_affixes }"
86- else
87- local -r fallback=" $empty_with_optional_affixes "
88- fi
89- fi
90-
91- local -r highlight_on_prefix=" #{?client_prefix,$prefix_with_optional_affixes ,$fallback }#[default]"
92- tmux set-option -gq " $status " " ${status_value/ $place_holder / $highlight_on_prefix } "
93- }
94-
9550main () {
9651 local -r \
9752 fg_color=$( tmux_option " $fg_color_config " " $default_fg " ) \
@@ -109,41 +64,41 @@ main() {
10964 empty_attr=$( tmux_option " $empty_attr_config " " $default_empty_attr " ) \
11065 empty_has_affixes=$( tmux_option " $empty_has_affixes " " off" )
11166
112- local -r \
113- prefix_highlight= " #[fg= $fg_color ,bg= $bg_color ] " \
114- copy_highlight= " ${copy_attr : + # [default,$copy_attr]} " \
115- sync_highlight =" ${sync_attr : + # [ default,$sync_attr]} " \
116- empty_highlight =" ${empty_attr : + # [default,$empty_attr]} "
117-
118- highlight " status-right " \
119- " $prefix_prompt " \
120- " $prefix_highlight " \
121- " $show_copy_mode " \
122- " $show_sync_mode " \
123- " $copy_highlight " \
124- " $sync_highlight " \
125- " $output_prefix " \
126- " $output_suffix " \
127- " $copy_prompt " \
128- " $sync_prompt " \
129- " $empty_prompt " \
130- " $empty_highlight " \
131- " $empty_has_affixes "
132-
133- highlight " status-left " \
134- " $prefix_prompt " \
135- " $prefix_highlight " \
136- " $show_copy_mode " \
137- " $show_sync_mode " \
138- " $copy_highlight " \
139- " $sync_highlight " \
140- " $output_prefix " \
141- " $output_suffix " \
142- " $copy_prompt " \
143- " $sync_prompt " \
144- " $empty_prompt " \
145- " $empty_highlight " \
146- " $empty_has_affixes "
67+ local -r prefix_highlight= " #[fg= $fg_color ]#[bg= $bg_color ] "
68+ local -r prefix_mode= " $prefix_highlight$output_prefix$prefix_prompt$output_suffix "
69+
70+ local -r copy_highlight =" $( format_style " ${copy_attr : + default,$copy_attr } " ) "
71+ local -r copy_mode =" $copy_highlight$output_prefix$copy_prompt$output_suffix "
72+
73+ local -r sync_highlight= " $( format_style " ${sync_attr : +default, $sync_attr } " ) "
74+ local -r sync_mode= " $sync_highlight$output_prefix$sync_prompt$output_suffix "
75+
76+ local -r empty_highlight= " $( format_style " ${empty_attr : +default, $empty_attr } " ) "
77+ if [[ " on " = " $empty_has_affixes " ]] ; then
78+ local -r empty_mode= " $empty_highlight$output_prefix$empty_prompt$output_suffix "
79+ else
80+ local -r empty_mode= " $empty_highlight$empty_prompt "
81+ fi
82+
83+ if [[ " on " = " $show_copy_mode " ]] ; then
84+ if [[ " on " = " $show_sync_mode " ]] ; then
85+ local -r fallback= " #{?pane_in_mode, $copy_mode ,#{?synchronize-panes, $sync_mode , $empty_mode }} "
86+ else
87+ local -r fallback= " #{?pane_in_mode, $copy_mode , $empty_mode } "
88+ fi
89+ elif [[ " on " = " $show_sync_mode " ]] ; then
90+ local -r fallback= " #{?synchronize-panes, $sync_mode , $empty_mode } "
91+ else
92+ local -r fallback= " $empty_mode "
93+ fi
94+
95+ local -r highlight= " #{?client_prefix, $prefix_mode , $fallback }#[default] "
96+
97+ local -r status_left_value= " $( tmux_option " status-left " ) "
98+ tmux set-option -gq " status-left " " ${status_left_value / $place_holder / $highlight } "
99+
100+ local -r status_right_value= " $( tmux_option " status-right " ) "
101+ tmux set-option -gq " status-right " " ${status_right_value / $place_holder / $highlight } "
147102}
148103
149104main
0 commit comments