|
# ============================================================================ |
|
# tmux Configuration - Ghostty-like Keybindings |
|
# ============================================================================ |
|
# |
|
# This config works with the companion Alacritty config to provide |
|
# Ghostty/iTerm2-style keyboard shortcuts via escape sequences. |
|
# |
|
# Location: ~/.tmux.conf |
|
# |
|
# After editing, reload with: |
|
# tmux source-file ~/.tmux.conf |
|
# Or press: Ctrl+b then r (if using this config) |
|
# |
|
# ============================================================================ |
|
|
|
# ============================================================================ |
|
# GENERAL SETTINGS |
|
# ============================================================================ |
|
|
|
# Use zsh as the default shell |
|
# Change to /bin/bash or /usr/bin/fish if preferred |
|
set -g default-shell /bin/zsh |
|
|
|
# Enable mouse support |
|
# - Click to select pane |
|
# - Drag to resize panes |
|
# - Scroll to enter copy mode |
|
set -g mouse on |
|
|
|
# Start window and pane numbering at 1 instead of 0 |
|
# Makes Cmd+1 go to the first window (more intuitive) |
|
set -g base-index 1 |
|
setw -g pane-base-index 1 |
|
|
|
# Renumber windows when one is closed |
|
# Prevents gaps like: 1, 2, 4, 5 after closing window 3 |
|
set -g renumber-windows on |
|
|
|
# ============================================================================ |
|
# TERMINAL & COLOR SETTINGS |
|
# ============================================================================ |
|
|
|
# Set TERM for proper color support |
|
# xterm-256color provides broad compatibility |
|
set -g default-terminal "xterm-256color" |
|
|
|
# Enable true color (24-bit RGB) for terminals that support it |
|
# This makes colors in vim, neovim, and other apps look correct |
|
set -ag terminal-overrides ",xterm-256color:RGB" |
|
|
|
# ============================================================================ |
|
# PERFORMANCE SETTINGS |
|
# ============================================================================ |
|
|
|
# Reduce escape-time (default is 500ms) |
|
# This is the time tmux waits after receiving an escape character |
|
# Lower = faster response, but too low may cause issues with slow connections |
|
# 10ms is a good balance for local use |
|
set -s escape-time 10 |
|
|
|
# Increase scrollback buffer (default is 2000) |
|
# This is how many lines you can scroll back in copy mode |
|
set -g history-limit 50000 |
|
|
|
# ============================================================================ |
|
# USER-DEFINED KEYS (ESCAPE SEQUENCE MAPPING) |
|
# ============================================================================ |
|
# |
|
# HOW THIS WORKS: |
|
# =============== |
|
# tmux can define "user keys" that map escape sequences to named keys. |
|
# When Alacritty sends \e[25;6~ (for example), tmux sees it as "User0". |
|
# We then bind User0 to an action like "split-window". |
|
# |
|
# The escape sequences must match exactly between Alacritty and tmux! |
|
# |
|
# FORMAT: set -s user-keys[N] "ESCAPE_SEQUENCE" |
|
# - N = index (0-999) |
|
# - Use \e for escape character (same as \033 or \x1b) |
|
# |
|
# ============================================================================ |
|
|
|
# Pane management |
|
set -s user-keys[0] "\e[25;6~" # Cmd+D (split right) |
|
set -s user-keys[1] "\e[26;6~" # Cmd+Shift+D (split down) |
|
set -s user-keys[2] "\e[28;6~" # Cmd+W (close pane) |
|
|
|
# Pane navigation |
|
set -s user-keys[3] "\e[29;6~" # Cmd+Left |
|
set -s user-keys[4] "\e[31;6~" # Cmd+Right |
|
set -s user-keys[5] "\e[32;6~" # Cmd+Up |
|
set -s user-keys[6] "\e[33;6~" # Cmd+Down |
|
|
|
# Window/session management |
|
set -s user-keys[7] "\e[34;6~" # Cmd+T (new window) |
|
set -s user-keys[8] "\e[35;6~" # Cmd+N (new session) |
|
|
|
# Window switching (Cmd+1 through Cmd+9) |
|
set -s user-keys[9] "\e[36;6~" # Cmd+1 |
|
set -s user-keys[10] "\e[37;6~" # Cmd+2 |
|
set -s user-keys[11] "\e[38;6~" # Cmd+3 |
|
set -s user-keys[12] "\e[39;6~" # Cmd+4 |
|
set -s user-keys[13] "\e[40;6~" # Cmd+5 |
|
set -s user-keys[14] "\e[41;6~" # Cmd+6 |
|
set -s user-keys[15] "\e[42;6~" # Cmd+7 |
|
set -s user-keys[16] "\e[43;6~" # Cmd+8 |
|
set -s user-keys[17] "\e[44;6~" # Cmd+9 |
|
|
|
# ============================================================================ |
|
# GHOSTTY-LIKE KEYBINDINGS (Cmd+key via Alacritty) |
|
# ============================================================================ |
|
# |
|
# BINDING SYNTAX: |
|
# =============== |
|
# bind -n UserN action |
|
# -n = "no prefix" (don't require Ctrl+b first) |
|
# UserN = the user-defined key from above |
|
# |
|
# SPLIT TERMINOLOGY: |
|
# ================== |
|
# tmux uses confusing terminology for splits: |
|
# split-window -h = "horizontal split" = pane appears to the RIGHT |
|
# split-window -v = "vertical split" = pane appears BELOW |
|
# |
|
# We follow Ghostty's convention: |
|
# Cmd+D = split right (what tmux calls "horizontal") |
|
# Cmd+Shift+D = split down (what tmux calls "vertical") |
|
# |
|
# ============================================================================ |
|
|
|
# --- Pane Splitting --- |
|
|
|
# Cmd+D: Split right (new pane to the right of current) |
|
# -h = horizontal split (creates panes side by side) |
|
# -c "#{pane_current_path}" = open in same directory as current pane |
|
bind -n User0 split-window -h -c "#{pane_current_path}" |
|
|
|
# Cmd+Shift+D: Split down (new pane below current) |
|
# -v = vertical split (creates panes stacked) |
|
bind -n User1 split-window -v -c "#{pane_current_path}" |
|
|
|
# --- Pane Management --- |
|
|
|
# Cmd+W: Close the current pane |
|
# If this is the last pane, it closes the window too |
|
bind -n User2 kill-pane |
|
|
|
# --- Pane Navigation --- |
|
|
|
# Cmd+Arrow: Move focus between panes |
|
bind -n User3 select-pane -L # Cmd+Left: go left |
|
bind -n User4 select-pane -R # Cmd+Right: go right |
|
bind -n User5 select-pane -U # Cmd+Up: go up |
|
bind -n User6 select-pane -D # Cmd+Down: go down |
|
|
|
# --- Window (Tab) Management --- |
|
|
|
# Cmd+T: Create new window (like a new tab) |
|
# Opens in the same directory as the current pane |
|
bind -n User7 new-window -c "#{pane_current_path}" |
|
|
|
# Cmd+N: Create new session (a whole new workspace) |
|
# Sessions are independent and can be detached/reattached |
|
bind -n User8 new-session |
|
|
|
# --- Window Switching --- |
|
|
|
# Cmd+1-9: Jump directly to window by number |
|
# Like switching tabs in a browser |
|
bind -n User9 select-window -t 1 |
|
bind -n User10 select-window -t 2 |
|
bind -n User11 select-window -t 3 |
|
bind -n User12 select-window -t 4 |
|
bind -n User13 select-window -t 5 |
|
bind -n User14 select-window -t 6 |
|
bind -n User15 select-window -t 7 |
|
bind -n User16 select-window -t 8 |
|
bind -n User17 select-window -t 9 |
|
|
|
# ============================================================================ |
|
# PREFIX-BASED KEYBINDINGS (Ctrl+b, then key) |
|
# ============================================================================ |
|
# |
|
# These work without Alacritty - useful when SSH'd to remote servers |
|
# or using other terminal emulators. |
|
# |
|
# Default prefix is Ctrl+b (press Ctrl+b, release, then press the key) |
|
# |
|
# ============================================================================ |
|
|
|
# Reload tmux config |
|
# Press: Ctrl+b, then r |
|
bind r source-file ~/.tmux.conf \; display "Config reloaded!" |
|
|
|
# --- Alternative split bindings --- |
|
# These are mnemonically memorable: |
|
# | looks like a vertical divider (split right) |
|
# - looks like a horizontal divider (split down) |
|
|
|
bind | split-window -h -c "#{pane_current_path}" |
|
bind - split-window -v -c "#{pane_current_path}" |
|
|
|
# --- Vim-style pane navigation --- |
|
# Press: Ctrl+b, then h/j/k/l |
|
|
|
bind h select-pane -L # Left |
|
bind j select-pane -D # Down |
|
bind k select-pane -U # Up |
|
bind l select-pane -R # Right |
|
|
|
# --- Pane resizing --- |
|
# Press: Ctrl+b, then Ctrl+h/j/k/l (hold Ctrl) |
|
# -r = repeatable (can press multiple times without prefix) |
|
|
|
bind -r C-h resize-pane -L 5 # Shrink left by 5 cells |
|
bind -r C-j resize-pane -D 5 # Shrink down by 5 cells |
|
bind -r C-k resize-pane -U 5 # Grow up by 5 cells |
|
bind -r C-l resize-pane -R 5 # Grow right by 5 cells |
|
|
|
# --- Pane zooming --- |
|
# Press: Ctrl+b, then z |
|
# Toggles current pane to fill entire window (and back) |
|
bind z resize-pane -Z |
|
|
|
# ============================================================================ |
|
# TIPS FOR NEW USERS |
|
# ============================================================================ |
|
# |
|
# SESSIONS: |
|
# tmux # Start new session |
|
# tmux new -s projectname # Start named session |
|
# tmux ls # List sessions |
|
# tmux attach -t name # Attach to session |
|
# Ctrl+b d # Detach from session (it keeps running!) |
|
# |
|
# WINDOWS (tabs): |
|
# Ctrl+b c # Create new window |
|
# Ctrl+b n # Next window |
|
# Ctrl+b p # Previous window |
|
# Ctrl+b 1-9 # Go to window by number |
|
# Ctrl+b , # Rename current window |
|
# |
|
# PANES (splits): |
|
# Ctrl+b % # Split right (default) |
|
# Ctrl+b " # Split down (default) |
|
# Ctrl+b x # Close pane (with confirmation) |
|
# Ctrl+b o # Cycle through panes |
|
# Ctrl+b Space # Cycle through layouts |
|
# |
|
# COPY MODE (scrollback): |
|
# Ctrl+b [ # Enter copy mode |
|
# q # Exit copy mode |
|
# Use arrow keys or vim keys (h/j/k/l) to navigate |
|
# Space to start selection, Enter to copy |
|
# |
|
# ============================================================================ |