Files
dotfiles/home/benk/.tmux.conf
2026-03-11 16:57:40 +00:00

88 lines
2.6 KiB
Bash

set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'
set -ga terminal-overrides ",xterm*:Tc"
set -sg escape-time 0
set -g history-limit 50000
# Set Fish as default shell (Apple Silicon path)
set-option -g default-shell /opt/homebrew/bin/fish
set-option -g default-command /opt/homebrew/bin/fish
unbind C-Enter
# --- Windows start at 1, auto-renumber ---
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
# --- Mouse ---
set -g mouse on
# --- Pane navigation (prefix + hjkl) ---
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# --- Pane resizing (prefix + C-hjkl, repeatable) ---
bind -r C-h resize-pane -L 4
bind -r C-j resize-pane -D 2
bind -r C-k resize-pane -U 2
bind -r C-l resize-pane -R 4
# --- Window navigation ---
bind C-p previous-window
bind C-n next-window
set -g repeat-time 1000
# --- Splits open in same directory ---
bind v split-window -h -c "#{pane_current_path}"
bind x split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# --- i3-style pane moving (prefix + H/J/K/L swaps panes) ---
# Try directional swap first; if no pane in that direction, break out and rejoin
bind H run-shell 'tmux swap-pane -s "{left-of}" 2>/dev/null; true'
bind J run-shell 'tmux swap-pane -s "{down-of}" 2>/dev/null; true'
bind K run-shell 'tmux swap-pane -s "{up-of}" 2>/dev/null; true'
bind L run-shell 'tmux swap-pane -s "{right-of}" 2>/dev/null; true'
# --- Window moving (prefix + < / > shifts window position) ---
bind -r < swap-window -t -1\; select-window -t -1
bind -r > swap-window -t +1\; select-window -t +1
# --- Break pane out / join pane back ---
# prefix + ! = break current pane into its own window (built-in)
# prefix + @ = pick a window and pull it back as a pane
bind @ command-prompt -p "join pane from window:" "join-pane -s '%%'"
# --- New window in same directory ---
bind c new-window -c "#{pane_current_path}"
# --- SSH into new window ---
bind S command-prompt -p "ssh:" "new-window -n '%1' 'ssh %1'"
# --- Reload config ---
bind r source-file ~/.tmux.conf \; display "Config reloaded"
# --- Status bar ---
set -g status-right ""
set -g status-style 'bg=#f5bde6 fg=#24273a'
set -g pane-active-border-style "bg=default fg=#f5bde6"
# --- Copy/paste (system clipboard via OSC 52 — works over SSH) ---
set -g set-clipboard on
setw -g mode-keys vi
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-selection
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection
# --- Plugins ---
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @resurrect-strategy-nvim 'session'
run '~/.tmux/plugins/tpm/tpm'