MunifTanjim / tmux-mode-indicator

Plugin that displays prompt indicating currently active Tmux mode.
https://git.io/tmux-mode-indicator
MIT License
143 stars 6 forks source link

[Enhancement] Colour separator based on mode indicator #5

Closed olimorris closed 2 years ago

olimorris commented 2 years ago

Firstly, I love the plugin. Simple, concise and just works.

I have a separator, which follows the mode indicator, as seen below:

Screen Shot 2022-03-15 at 08 04 02@2x

It's just a typical powerline separator. However when I change the mode, of course the separator stays the same color:

Screen Shot 2022-03-15 at 08 06 15@2x

That is because my config is:

set -g status-left "#{tmux_mode_indicator}#[fg=$color_purple] #[fg=$color_gray]#{online_status}  %R "

It would be great if there was a way to color the separator based on the current mode and its defined style.

MunifTanjim commented 2 years ago

Have you tried doing:

set -g @mode_indicator_prefix_prompt ' WAIT #[fg=$color_green] '
olimorris commented 2 years ago

I have just now and unfortunately it doesn't seem to apply any formatting to the separator at all

MunifTanjim commented 2 years ago

My bad, can you try it with double quote?

set -g @mode_indicator_prefix_prompt " WAIT #[fg=$color_green] "

Assuming you have $color_green environment variable set.

olimorris commented 2 years ago

Still no luck unfortunately. I do have those env vars set and to be explicit, this is my relevant config:

color_bg="#f0f0f0"
color_fg="#6a6a6a"
color_green="#1da912"
color_yellow="#eea825"
color_red="#e05661"
color_blue="#118dc3"
color_purple="#9a77cf"
color_gray="#b5b5b5"
color_selection="#bfceff"

set -g @mode_indicator_prefix_prompt " WAIT #[fg=$color_green]"
set -g @mode_indicator_prefix_mode_style bg=$color_green,fg=$color_bg
set -g @mode_indicator_copy_prompt " COPY #[fg=$color_blue]"
set -g @mode_indicator_copy_mode_style bg=$color_blue,fg=$color_bg
set -g @mode_indicator_sync_prompt " SYNC #[fg=$color_red]"
set -g @mode_indicator_sync_mode_style bg=$color_red,fg=$color_bg
set -g @mode_indicator_empty_prompt " TMUX #[fg=$color_purple]"
set -g @mode_indicator_empty_mode_style bg=$color_purple,fg=$color_bg

mode_separator=""
set -g status-left "#{tmux_mode_indicator}#{mode_separator} "
MunifTanjim commented 2 years ago

This is what you need:

mode_separator=" "
set -g @mode_indicator_prefix_prompt " WAIT #[default]#[fg=$color_green]$mode_separator"
set -g @mode_indicator_prefix_mode_style bg=$color_green,fg=$color_bg
set -g @mode_indicator_copy_prompt " COPY #[default]#[fg=$color_blue]$mode_separator"
set -g @mode_indicator_copy_mode_style bg=$color_blue,fg=$color_bg
set -g @mode_indicator_sync_prompt " SYNC #[default]#[fg=$color_red]$mode_separator"
set -g @mode_indicator_sync_mode_style bg=$color_red,fg=$color_bg
set -g @mode_indicator_empty_prompt " TMUX #[default]#[fg=$color_purple]$mode_separator"
set -g @mode_indicator_empty_mode_style bg=$color_purple,fg=$color_bg

Or you can do this:

mode_separator="#[default]#{?client_prefix,#[fg=$color_green],#{?pane_in_mode,#[fg=$color_blue],#{?pane_synchronized,#[fg=$color_red],#[fg=$color_purple]}}} "
set -g @mode_indicator_prefix_prompt " WAIT $mode_separator"
set -g @mode_indicator_prefix_mode_style bg=$color_green,fg=$color_bg
set -g @mode_indicator_copy_prompt " COPY $mode_separator"
set -g @mode_indicator_copy_mode_style bg=$color_blue,fg=$color_bg
set -g @mode_indicator_sync_prompt " SYNC $mode_separator"
set -g @mode_indicator_sync_mode_style bg=$color_red,fg=$color_bg
set -g @mode_indicator_empty_prompt " TMUX $mode_separator"
set -g @mode_indicator_empty_mode_style bg=$color_purple,fg=$color_bg

Or basically you can put whatever you want in those @mode_indicator_*_prompt variables.

olimorris commented 2 years ago

The first one is such a beautifully elegant solution. Many thanks, greatly appreciated.