Skip to content

Commit 1db6e73

Browse files
authored
Restore original behavior (tmux-plugins#21)
1 parent 3435925 commit 1db6e73

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

prefix_highlight.tmux

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ tmux_option() {
3232
fi
3333
}
3434

35+
escape_symbols() {
36+
local -r string="$1"
37+
echo "$string" | sed -e 's/,/#,/g' -e 's/}/#}/g'
38+
}
39+
3540
# Defaults
3641
default_fg='colour231'
3742
default_bg='colour04'
@@ -46,41 +51,44 @@ default_empty_prompt=''
4651
highlight() {
4752
local -r \
4853
status="$1" \
49-
prefix="$2" \
50-
prefix_highlight="$3" \
54+
prefix="$(escape_symbols "$2")" \
55+
prefix_highlight="$(escape_symbols "$3")" \
5156
show_copy_mode="$4" \
5257
show_sync_mode="$5" \
53-
copy_highlight="$6" \
54-
sync_highlight="$7" \
55-
output_prefix="$8" \
56-
output_suffix="$9" \
57-
copy="${10}" \
58-
sync="${11}" \
59-
empty="${12}"
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}")"
6065

6166
local -r status_value="$(tmux_option "$status")"
62-
local -r prefix_with_optional_affixes="$output_prefix$prefix$output_suffix"
63-
local -r copy_with_optional_affixes="$output_prefix$copy$output_suffix"
64-
local -r sync_with_optional_affixes="$output_prefix$sync$output_suffix"
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"
6570

6671
if [[ "on" = "$empty_has_affixes" ]]; then
67-
local -r empty_with_optional_affixes="$output_prefix$empty$output_suffix"
72+
local -r empty_with_optional_affixes="$empty_highlight$output_prefix$empty$output_suffix"
6873
else
69-
local -r empty_with_optional_affixes="$empty"
74+
local -r empty_with_optional_affixes="$empty_highlight$empty"
7075
fi
7176

7277
if [[ "on" = "$show_copy_mode" ]]; then
73-
local -r copy_mode="${copy_highlight}#{?pane_in_mode,$copy_with_optional_affixes,}"
74-
fi
75-
76-
if [[ "on" = "$show_sync_mode" ]]; then
77-
local -r sync_panes="${sync_highlight}#{?synchronize-panes,$sync_with_optional_affixes,}"
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
7889
fi
7990

80-
local -r extended_highlights="${copy_mode}${sync_panes}"
81-
local -r client_prefix="#{?client_prefix,$prefix_with_optional_affixes,${empty_highlight}$empty_with_optional_affixes}"
82-
83-
local -r highlight_on_prefix="${prefix_highlight}${client_prefix}${extended_highlights}#[default]"
91+
local -r highlight_on_prefix="#{?client_prefix,$prefix_with_optional_affixes,$fallback}#[default]"
8492
tmux set-option -gq "$status" "${status_value/$place_holder/$highlight_on_prefix}"
8593
}
8694

0 commit comments

Comments
 (0)