Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ set -g @mode_indicator_sync_prompt ' SYNC '
# prompt to display when tmux is in normal mode
set -g @mode_indicator_empty_prompt ' TMUX '

# prompt to display when tmux is in a user's key table using `switch-client -T <key-table>`
set -g @mode_indicator_keytable_prompt '#{client_key_table}'

# style values for prefix prompt
set -g @mode_indicator_prefix_mode_style 'bg=blue,fg=black'

Expand All @@ -84,6 +87,9 @@ set -g @mode_indicator_sync_mode_style 'bg=red,fg=black'

# style values for empty prompt
set -g @mode_indicator_empty_mode_style 'bg=cyan,fg=black'

# style values for key table prompt
set -g @mode_indicator_keytable_mode_style 'bg=magenta,fg=black'
```

### Custom Indicator
Expand Down
20 changes: 17 additions & 3 deletions mode_indicator.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ declare -r prefix_prompt_config='@mode_indicator_prefix_prompt'
declare -r copy_prompt_config='@mode_indicator_copy_prompt'
declare -r sync_prompt_config='@mode_indicator_sync_prompt'
declare -r empty_prompt_config='@mode_indicator_empty_prompt'
declare -r keytable_prompt_config='@mode_indicator_keytable_prompt'
declare -r custom_prompt_config="@mode_indicator_custom_prompt"
declare -r prefix_mode_style_config='@mode_indicator_prefix_mode_style'
declare -r copy_mode_style_config='@mode_indicator_copy_mode_style'
declare -r sync_mode_style_config='@mode_indicator_sync_mode_style'
declare -r empty_mode_style_config='@mode_indicator_empty_mode_style'
declare -r keytable_mode_style_config='@mode_indicator_keytable_mode_style'
declare -r custom_mode_style_config="@mode_indicator_custom_mode_style"

tmux_option() {
Expand All @@ -32,18 +34,30 @@ init_tmux_mode_indicator() {
copy_prompt=$(tmux_option "$copy_prompt_config" " COPY ") \
sync_prompt=$(tmux_option "$sync_prompt_config" " SYNC ") \
empty_prompt=$(tmux_option "$empty_prompt_config" " TMUX ") \
keytable_prompt=$(tmux_option "$keytable_prompt_config" " #{client_key_table} ") \
prefix_style=$(indicator_style "$prefix_mode_style_config" "bg=blue,fg=black") \
copy_style=$(indicator_style "$copy_mode_style_config" "bg=yellow,fg=black") \
sync_style=$(indicator_style "$sync_mode_style_config" "bg=red,fg=black") \
empty_style=$(indicator_style "$empty_mode_style_config" "bg=cyan,fg=black")
empty_style=$(indicator_style "$empty_mode_style_config" "bg=cyan,fg=black") \
keytable_style=$(indicator_style "$keytable_mode_style_config" "bg=magenta,fg=black")

local -r \
custom_prompt="#(tmux show-option -qv $custom_prompt_config)" \
custom_style="#(tmux show-option -qv $custom_mode_style_config)"

local -r \
mode_prompt="#{?#{!=:$custom_prompt,},$custom_prompt,#{?client_prefix,$prefix_prompt,#{?pane_in_mode,$copy_prompt,#{?pane_synchronized,$sync_prompt,$empty_prompt}}}}" \
mode_style="#{?#{!=:$custom_style,},#[$custom_style],#{?client_prefix,$prefix_style,#{?pane_in_mode,$copy_style,#{?pane_synchronized,$sync_style,$empty_style}}}}"
mode_prompt="\
#{?#{!=:$custom_prompt,},$custom_prompt,\
#{?#{==:#{client_key_table},prefix},$prefix_prompt,\
#{?pane_in_mode,$copy_prompt,\
#{?#{!=:#{client_key_table},root},$keytable_prompt,\
#{?pane_synchronized,$sync_prompt,$empty_prompt}}}}}" \
mode_style="\
#{?#{!=:$custom_style,},#[$custom_style],\
#{?#{==:#{client_key_table},prefix},$prefix_style,\
#{?pane_in_mode,$copy_style,\
#{?#{!=:#{client_key_table},root},$keytable_style,\
#{?pane_synchronized,$sync_style,$empty_style}}}}}"

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

Expand Down