fix(tmux): always-on Neovim-style NORMAL/VISUAL mode indicator
NORMAL = always visible when working in tmux (green) VISUAL = switches in when entering copy-mode via prefix+Enter (blue) Uses pane-mode-changed hook with -F flag for clean format evaluation. Default @mode_indicator set to NORMAL on config load.
This commit is contained in:
+14
-28
@@ -366,36 +366,22 @@ 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.
|
||||
# ── Mode indicator (always-on, Neovim-style) ──────────────────────────────────
|
||||
# NORMAL = working in tmux (default, always visible)
|
||||
# VISUAL = in copy-mode (prefix + Enter)
|
||||
#
|
||||
# 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
|
||||
# #{@mode_indicator} is a window user-option set via pane-mode-changed hook.
|
||||
# We use -F flag so #{pane_in_mode} is evaluated as a tmux format (1=in mode).
|
||||
# This bypasses oh-my-tmux's awk pipeline which mangles inline #{?...} conditionals.
|
||||
|
||||
# Set NORMAL as the default on startup
|
||||
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 \""
|
||||
}
|
||||
|
||||
# Switch between NORMAL and VISUAL whenever the pane mode changes
|
||||
set-hook -g pane-mode-changed \
|
||||
'if-shell -F "#{pane_in_mode}" \
|
||||
"set-window-option -g @mode_indicator \"#[fg=#78a9ff,bold] VISUAL \"" \
|
||||
"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
|
||||
|
||||
Reference in New Issue
Block a user