From a8f69739689ae0fe9a876bc211be42b5789d28e9 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Mon, 27 Jun 2022 12:05:21 +0200 Subject: [PATCH] tmux: Use pane-border as indicator for {copy,sync} In tmux version 3.2 all style options were changed to string options, making them support formats.[^1] From that version on, use the pane-borders as indicator for the {copy,sync}-mode instead of the prefix_highlight plugin. Keep the pure style fallback, as Ubuntu 20.4 for example still only ships with version 3.0a. [^1]: https://github.com/tmux/tmux/commit/f03b61131b34079 --- .config/tmux/tmux.conf | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 7fa20bd..c8b3447 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -134,17 +134,30 @@ set -g status-style bg=default,fg=white set -g message-command-style bg=default,fg=brightyellow set -g message-style bg=brightyellow,fg=black set -g mode-style bg=brightyellow,fg=black -set -g pane-border-style bg=default,fg=brightblack -set -g pane-active-border-style bg=default,fg=brightyellow + +# NOTE: `<` does string comparison with `strcmp()`. This means that the +# condition will break from a double digit major version (e.g. `10.0`) on. +if -F "#{<:#{version},3.2}" { + # Use pure style default for tmux < 3.2 in combination with the + # prefix_highlight plugin. + set -g pane-border-style bg=default,fg=brightblack + set -g pane-active-border-style bg=default,fg=brightyellow + + set -g @prefix_highlight_show_copy_mode 'on' + set -g @prefix_highlight_show_sync_mode 'on' + set -g @prefix_highlight_copy_mode_attr 'fg=black,bg=brightyellow' + set -g @prefix_highlight_sync_mode_attr 'fg=black,bg=brightred' +} { + # From 3.2 on, we can use formats in styles, so that all indicators can be + # done by the borders. + set -g pane-border-style "#{?synchronize-panes,fg=brightred,fg=brightblack}" + set -g pane-active-border-style "#{?pane_in_mode,bg=brightyellow#,fg=brightblack,#{?synchronize-panes,fg=brightred,fg=brightyellow}}" +} # Display in the status bar when the prefix was pressed, copy-mode is active, or # `synchronize-panes` is turned on set -g @prefix_highlight_fg 'brightyellow' set -g @prefix_highlight_bg 'default' -set -g @prefix_highlight_show_copy_mode 'on' -set -g @prefix_highlight_show_sync_mode 'on' -set -g @prefix_highlight_copy_mode_attr 'fg=black,bg=brightyellow' -set -g @prefix_highlight_sync_mode_attr 'fg=black,bg=brightred' set -g status-right "#{prefix_highlight}" set -g status-left "#{prefix_highlight}"