Files
sethmux/config/tmux.conf
T
Mortdecai 3b06ce752d fix: keep tmux selection alive after mouse-drag in copy mode
Change MouseDragEnd1Pane from copy-selection-and-cancel to
copy-selection so a drag-select copies but stays in copy mode,
letting you re-select without re-entering copy mode each time.
Press 'q' to exit when done.
2026-04-24 19:50:24 -04:00

163 lines
5.5 KiB
Bash

# sethmux — kitty-compatible keybindings for tmux
# Mirrors kitty's Ctrl+Shift+key shortcuts via extended-keys (CSI u)
# Dvorak-optimized, mobile-friendly, built for AI CLI workflows
# --- Extended keys (required for Ctrl+Shift detection) ---
set -g extended-keys on
set -g extended-keys-format csi-u
# --- No prefix for kitty-style bindings ---
# Kitty uses Ctrl+Shift+key directly, no prefix needed.
# We keep Ctrl-A as prefix for tmux-native stuff (capture, logging, etc.)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# ============================================================
# Kitty-compatible keybindings (Ctrl+Shift+key)
# ============================================================
# --- Tab management ---
bind -n C-S-t new-window -c "#{pane_current_path}"
bind -n C-S-w kill-window
bind -n C-S-Right next-window
bind -n C-S-Left previous-window
# Ctrl+Shift+1-9 = goto tab (tmux base-index 1)
bind -n C-S-1 select-window -t 1
bind -n C-S-2 select-window -t 2
bind -n C-S-3 select-window -t 3
bind -n C-S-4 select-window -t 4
bind -n C-S-5 select-window -t 5
bind -n C-S-6 select-window -t 6
bind -n C-S-7 select-window -t 7
bind -n C-S-8 select-window -t 8
bind -n C-S-9 select-window -t 9
# Ctrl+Shift+. / , = move tab forward/backward
bind -n C-S-. swap-window -t +1 \; next-window
bind -n C-S-, swap-window -t -1 \; previous-window
# --- Window/split management ---
# Ctrl+Shift+Enter = new split (kitty calls these "windows")
bind -n C-S-Enter split-window -v -c "#{pane_current_path}"
# Ctrl+Shift+] / [ = next/previous pane
bind -n C-S-] select-pane -t :.+
bind -n C-S-[ select-pane -t :.-
# Ctrl+Shift+l = next layout (cycle through layouts)
bind -n C-S-l next-layout
# --- Scrolling ---
bind -n C-S-Up copy-mode \; send -X scroll-up
bind -n C-S-Down copy-mode \; send -X scroll-down
bind -n C-S-PageUp copy-mode \; send -X page-up
bind -n C-S-PageDown copy-mode \; send -X page-down
bind -n C-S-Home copy-mode \; send -X history-top
bind -n C-S-End copy-mode \; send -X history-bottom
# Ctrl+Shift+h = show scrollback in pager (like kitty's show_scrollback)
bind -n C-S-h capture-pane -pS - \; save-buffer /tmp/sethmux-scrollback.txt \; new-window "less +G /tmp/sethmux-scrollback.txt"
# --- Clipboard ---
# Ctrl+Shift+c = copy (enter copy mode, or copy selection if in copy mode)
bind -n C-S-c copy-mode
bind -T copy-mode-vi C-S-c send -X copy-selection-and-cancel
# Ctrl+Shift+v = paste from tmux buffer
bind -n C-S-v paste-buffer
# --- Clear terminal ---
# Ctrl+Shift+Delete = clear terminal + scrollback
bind -n C-S-DC send-keys C-l \; clear-history
# --- Fullscreen ---
# F11 = toggle pane zoom (closest to kitty's fullscreen)
bind -n F11 resize-pane -Z
# ============================================================
# Dvorak-friendly extras (prefix Ctrl-A)
# ============================================================
bind s split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
bind z resize-pane -Z
bind c new-window -c "#{pane_current_path}"
bind o select-pane -t :.+
# --- Alt shortcuts (no prefix, kept for mobile/quick access) ---
bind -n M-t new-window -c "#{pane_current_path}"
bind -n M-w kill-window
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-Left previous-window
bind -n M-Right next-window
# ============================================================
# AI CLI workflow features
# ============================================================
# --- Mouse ---
set -g mouse on
# --- Scrollback (huge for AI output) ---
set -g history-limit 200000
# --- Copy mode (vi-style) ---
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-and-cancel
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection
# --- Capture & logging ---
bind S run-shell 'tmux capture-pane -pS - > ~/logs/capture-#S-#I-#P-$(date +%%s).txt && tmux display "Pane captured to ~/logs/"'
bind L pipe-pane -o 'cat >> ~/logs/live-#S-#I.log' \; display "Logging toggled"
# --- Clipboard ---
set -g set-clipboard on
# ============================================================
# Appearance
# ============================================================
# --- Numbering ---
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
# --- Adaptive resize ---
setw -g aggressive-resize on
set -g focus-events on
# --- Status bar: git branch + cwd ---
set -g status-style "bg=#1a1a1a,fg=#e0e0e0"
set -g status-left "#[bg=#D35400,fg=#0a0a0a,bold] #S #[bg=#1a1a1a] "
set -g status-right "#[fg=#666666]#{pane_current_path} #[fg=#D35400]#{?#{==:#{pane_current_command},bash},#(cd #{pane_current_path} && git branch --show-current 2>/dev/null),} #[fg=#666666]| #[fg=#e0e0e0]%H:%M"
set -g status-right-length 80
set -g status-left-length 20
set -g status-interval 5
# --- Window status ---
setw -g window-status-format " #[fg=#888888]#I:#W "
setw -g window-status-current-format "#[bg=#D35400,fg=#0a0a0a,bold] #I:#W "
setw -g window-status-separator ""
# --- Pane borders ---
set -g pane-border-style "fg=#333333"
set -g pane-active-border-style "fg=#D35400"
# --- Terminal ---
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
set -sg escape-time 10
# --- Help tab shortcut ---
# Ctrl-A ? = jump to help tab (or recreate if closed)
bind ? if-shell 'tmux select-window -t help 2>/dev/null' '' 'new-window -n help /opt/sethmux/sethmux-help.sh'
# --- Session startup layout ---
# Windows created by sethmux-start.sh: code, git, run, logs, help