Files
nixos-config/modules/user/config/tmux.conf
T
kiskaadee 53847d3496 refactor(input): harmonize word deletion and modifier keybindings across bash, nvim, tmux, and alacritty
This commit standardizes and refines word deletion behavior and modifier key handling across the entire terminal and editor stack.

- Bash: Add interactive Readline keybindings for `Ctrl+W`, `Ctrl+Delete`, and `Ctrl+Backspace` word deletion.
- Neovim: Configure precision word deletion shortcuts in insert and normal modes.
- Tmux: Enable `extended-keys` and terminal feature flags to pass modifier combos.
- Alacritty: Bind `Ctrl+Delete` and `Ctrl+Back` to raw ANSI escape sequences.
2026-08-30 09:51:58 -05:00

117 lines
4.2 KiB
Bash

# ==============================================================================
# Tmux Configuration
# Neovim / Wayland / Alacritty integration
# ==============================================================================
# ------------------------------------------------------------------------------
# Terminal & Colors
# ------------------------------------------------------------------------------
set -g default-terminal "tmux-256color"
# Advertise true color / RGB and extended keys support to terminal applications (Neovim, etc.)
set -as terminal-features ',*:RGB'
set -as terminal-features 'xterm*:extkeys'
set -s extended-keys on
# 1-based indexing for windows and panes (matches keyboard row 1..9)
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
# ------------------------------------------------------------------------------
# General Behavior & Flow Control
# ------------------------------------------------------------------------------
set -g mouse on
set -g focus-events on
set -g history-limit 10000
# Zero delay for escape key responsiveness in Vim/Neovim
set -s escape-time 0
# Keep panes at their current size when the window is resized
setw -g aggressive-resize off
# Vim-style status and copy mode navigation
set -g status-keys vi
set -g mode-keys vi
# ------------------------------------------------------------------------------
# Prefix Key (Ctrl-Space)
# ------------------------------------------------------------------------------
unbind C-b
unbind C-s
set -g prefix C-Space
bind C-Space send-prefix
# ------------------------------------------------------------------------------
# Pane Creation (Shared Mental Model: | for vertical, - for horizontal)
# ------------------------------------------------------------------------------
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# ------------------------------------------------------------------------------
# Seamless Neovim <-> tmux Navigation (Ctrl-h/j/k/l)
# ------------------------------------------------------------------------------
# Smart pane switching with awareness of Vim/Neovim splits.
# When in Neovim, pass Ctrl-h/j/k/l through to Neovim.
# When in shell or at the edge of Neovim, tmux handles pane switching.
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
# Fallback explicit tmux-only navigation via prefix + h/j/k/l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# ------------------------------------------------------------------------------
# Pane Resizing (prefix + H/J/K/L)
# ------------------------------------------------------------------------------
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# ------------------------------------------------------------------------------
# Copy Mode & Clipboard (Vi-Style + OSC 52 Terminal Clipboard)
# ------------------------------------------------------------------------------
bind Escape copy-mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
# Copy selection to tmux buffer and system clipboard through OSC 52
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Allow tmux to set the system clipboard via terminal OSC 52 sequences (works locally & over SSH)
set -s set-clipboard on
# ------------------------------------------------------------------------------
# Configuration Reload
# ------------------------------------------------------------------------------
bind r source-file ~/.config/tmux/tmux.conf \; display-message "Tmux config reloaded"
# ------------------------------------------------------------------------------
# UI Adjustments
# ------------------------------------------------------------------------------
set -g status-position top
set -g clock-mode-style 12