Skip to content

Commit 253df37

Browse files
committed
support custom indicator
1 parent 466cf0b commit 253df37

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ set -g @mode_indicator_sync_mode_style 'bg=red,fg=black'
8686
set -g @mode_indicator_empty_mode_style 'bg=cyan,fg=black'
8787
```
8888

89+
### Custom Indicator
90+
91+
You can override the indicator at any time by setting these variables:
92+
93+
```ini
94+
# prompt to display instead of default mode indicators
95+
set -g @mode_indicator_custom_prompt ' ---- '
96+
97+
# style values for custom prompt
98+
set -g @mode_indicator_custom_mode_style 'default'
99+
```
100+
101+
To revert back to the default mode indicators, unset those variables:
102+
103+
```ini
104+
set -gu @mode_indicator_custom_prompt
105+
106+
set -gu @mode_indicator_custom_mode_style
107+
```
108+
89109
## License
90110

91111
Licensed under the MIT License. Check the [LICENSE](./LICENSE) file for details.

mode_indicator.tmux

+18-12
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
set -e
44

5-
mode_indicator_placeholder="\#{tmux_mode_indicator}"
6-
7-
prefix_prompt_config='@mode_indicator_prefix_prompt'
8-
copy_prompt_config='@mode_indicator_copy_prompt'
9-
sync_prompt_config='@mode_indicator_sync_prompt'
10-
empty_prompt_config='@mode_indicator_empty_prompt'
11-
prefix_mode_style_config='@mode_indicator_prefix_mode_style'
12-
copy_mode_style_config='@mode_indicator_copy_mode_style'
13-
sync_mode_style_config='@mode_indicator_sync_mode_style'
14-
empty_mode_style_config='@mode_indicator_empty_mode_style'
5+
declare -r mode_indicator_placeholder="\#{tmux_mode_indicator}"
6+
7+
declare -r prefix_prompt_config='@mode_indicator_prefix_prompt'
8+
declare -r copy_prompt_config='@mode_indicator_copy_prompt'
9+
declare -r sync_prompt_config='@mode_indicator_sync_prompt'
10+
declare -r empty_prompt_config='@mode_indicator_empty_prompt'
11+
declare -r custom_prompt_config="@mode_indicator_custom_prompt"
12+
declare -r prefix_mode_style_config='@mode_indicator_prefix_mode_style'
13+
declare -r copy_mode_style_config='@mode_indicator_copy_mode_style'
14+
declare -r sync_mode_style_config='@mode_indicator_sync_mode_style'
15+
declare -r empty_mode_style_config='@mode_indicator_empty_mode_style'
16+
declare -r custom_mode_style_config="@mode_indicator_custom_mode_style"
1517

1618
tmux_option() {
1719
local -r option=$(tmux show-option -gqv "$1")
@@ -36,8 +38,12 @@ init_tmux_mode_indicator() {
3638
empty_style=$(indicator_style "$empty_mode_style_config" "bg=cyan,fg=black")
3739

3840
local -r \
39-
mode_prompt="#{?client_prefix,$prefix_prompt,#{?pane_in_mode,$copy_prompt,#{?pane_synchronized,$sync_prompt,$empty_prompt}}}" \
40-
mode_style="#{?client_prefix,$prefix_style,#{?pane_in_mode,$copy_style,#{?pane_synchronized,$sync_style,$empty_style}}}"
41+
custom_prompt="#(tmux show-option -gqv $custom_prompt_config)" \
42+
custom_style="#(tmux show-option -gqv $custom_mode_style_config)"
43+
44+
local -r \
45+
mode_prompt="#{?#{!=:$custom_prompt,},$custom_prompt,#{?client_prefix,$prefix_prompt,#{?pane_in_mode,$copy_prompt,#{?pane_synchronized,$sync_prompt,$empty_prompt}}}}" \
46+
mode_style="#{?#{!=:$custom_style,},#[$custom_style],#{?client_prefix,$prefix_style,#{?pane_in_mode,$copy_style,#{?pane_synchronized,$sync_style,$empty_style}}}}"
4147

4248
local -r mode_indicator="#[default]$mode_style$mode_prompt#[default]"
4349

0 commit comments

Comments
 (0)