From 04b03d85cdac62fa51c19c62168fcc57e689f0fb Mon Sep 17 00:00:00 2001 From: Sarthak Jain Date: Sat, 18 Jul 2026 14:44:53 +0530 Subject: [PATCH] fix(tmux): fix NORMAL/VISUAL mode indicators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #{?pane_in_mode,...} inline conditional was getting mangled by oh-my-tmux's awk/sed pipeline that processes tmux_conf_theme_status_right. Fix: use #{@mode_indicator} user-option in status_right, driven by: - bind Enter → sets NORMAL indicator (green) on copy-mode entry - bind v → sets VISUAL indicator (blue) on selection start - bind y/Esc → clears indicator on copy/exit - pane-mode-changed hook → clears indicator when mode exits Also fixed: encoding artifacts in status_right, missing bullet separator. --- tmux/.tmux.conf.local | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tmux/.tmux.conf.local b/tmux/.tmux.conf.local index 13adbb4..8ce02ab 100644 --- a/tmux/.tmux.conf.local +++ b/tmux/.tmux.conf.local @@ -263,7 +263,7 @@ tmux_conf_theme_status_left_fg="default" tmux_conf_theme_status_left_bg="default" tmux_conf_theme_status_left_attr="none" -tmux_conf_theme_status_right=" #{prefix}#{mouse}#{pairing}#{synchronized}#{?pane_in_mode,#{?selection_active,#[fg=$color_blue,bg=default,bold] VISUAL,#[fg=$color_green,bg=default,bold] NORMAL},} | #[fg=$color_fg,bg=default,none]󰔚 #{?uptime_d,#{uptime_d}d,}#{?uptime_h,#{uptime_h}h,}#{?uptime_m,#{uptime_m}m,} #[fg=$color_gray]│ #[fg=$color_cyan,bg=default,bold]󱑒 %d %b %H:%M #[fg=$color_gray]│ #[fg=$color_purple,bg=default,bold]󰊪 #{username}#{root}@#{hostname}" +tmux_conf_theme_status_right=" #{prefix}#{mouse}#{pairing}#{synchronized}#{@mode_indicator} | #[fg=$color_fg,bg=default,none]󰔚 #{?uptime_d,#{uptime_d}d,}#{?uptime_h,#{uptime_h}h,}#{?uptime_m,#{uptime_m}m,} #[fg=$color_gray]│ #[fg=$color_cyan,bg=default,bold]󱑒 %d %b %H:%M #[fg=$color_gray]│ #[fg=$color_purple,bg=default,bold]󰊪 #{username}#{root}@#{hostname}" # status right style tmux_conf_theme_status_right_fg="$color_red,$color_fg" @@ -366,6 +366,37 @@ source-file "/Users/jsarthak/dotfiles/tmux/config/keybindings.conf" setw -g window-status-separator " #[fg=#484848]• " #!important +# ── Mode indicators via hooks ───────────────────────────────────────────────── +# oh-my-tmux's awk pipeline mangles #{?pane_in_mode,...} inline conditionals, +# so we drive @mode_indicator via hooks instead. +# +# Clear indicator when exiting copy-mode +set-hook -g pane-mode-changed \ + 'if-shell "tmux display-message -p \"#{pane_in_mode}\" | grep -q 1" \ + "" \ + "set-window-option -g @mode_indicator \"\""' +# +# NORMAL mode (entered copy-mode, no selection yet) +bind-key -T copy-mode-vi Escape { send -X cancel; set-window-option -g @mode_indicator "" } +bind-key -T copy-mode-vi v { + send -X begin-selection + set-window-option -g @mode_indicator "#[fg=#78a9ff,bold] VISUAL " +} +bind-key -T copy-mode-vi y { + send -X copy-selection-and-cancel + set-window-option -g @mode_indicator "" +} +# Set NORMAL indicator on copy-mode entry (overrides keybindings.conf Enter bind) +bind Enter { + copy-mode + set-window-option -g @mode_indicator "#[fg=#25be6a,bold] NORMAL " +} +bind -T root MouseDrag1Pane { + if-shell -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" \ + "send-keys -M" \ + "copy-mode -e; set-window-option -g @mode_indicator \"#[fg=#25be6a,bold] NORMAL \"" +} + # ── Per-machine local override (untracked) ──────────────────────────────────── # Create ~/.tmux.conf.machine.local on each machine for host-specific tweaks # (e.g. different color scheme, right-side content, etc.)