# Tmux Configuration for Ghostty Terminal
# ========================================
# Change prefix from Ctrl-b to Ctrl-a (easier to reach)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse support (click, scroll, resize)
set -g mouse on
# Use 256 color terminal
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"
# Enable true color support for Ghostty
set-option -sa terminal-overrides ",*:RGB"
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# Renumber windows when one is closed
set -g renumber-windows on
# Increase scrollback buffer size
set -g history-limit 50000
# Display messages for 4 seconds
set -g display-time 4000
# Refresh status bar every 5 seconds
set -g status-interval 5
# Focus events enabled for terminals that support them
set -g focus-events on
# Enable aggressive resize
setw -g aggressive-resize on
# ========================================
# Key Bindings
# ========================================
# Reload config file with Prefix + r
unbind r
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
# Split windows - Option+f for vertical, Option+Shift+f for horizontal (no prefix needed)
# Note: Tmux can't use Command key directly, using Option/Alt instead
bind -n M-f split-window -h -c "#{pane_current_path}"
bind -n M-F split-window -v -c "#{pane_current_path}"
# Alternative: Prefix + | for vertical, Prefix + - for horizontal
unbind %
bind | split-window -h -c "#{pane_current_path}"
unbind '"'
bind - split-window -v -c "#{pane_current_path}"
# Create new window in current path
bind c new-window -c "#{pane_current_path}"
# Vim-like pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Resize panes with Vim-like keys (Prefix + Shift + hjkl)
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
# Quick window navigation
bind -n M-h previous-window
bind -n M-l next-window
# Kill pane without confirmation
bind x kill-pane
# Kill window without confirmation
bind X kill-window
# Easy mode: Alt+m opens a menu of every common action, no prefix to remember
bind -n M-m display-menu -T "#[align=centre] tmux " \
"Split right" r "split-window -h -c '#{pane_current_path}'" \
"Split down" d "split-window -v -c '#{pane_current_path}'" \
"New tab (window)" t "new-window -c '#{pane_current_path}'" \
"Zoom pane" z "resize-pane -Z" \
"" \
"Switch session/tab" s "choose-tree -Zs" \
"New session" n "command-prompt -p 'Session name:' 'new-session -s %%'" \
"Rename tab" , "command-prompt -I '#W' 'rename-window %%'" \
"Rename session" $ "command-prompt -I '#S' 'rename-session %%'" \
"" \
"Scroll / copy" c "copy-mode" \
"Close pane" x "kill-pane" \
"Detach (keeps running)" q "detach-client" \
"Reload config" R "source-file ~/.tmux.conf"
# No-prefix movement: Alt+arrows between panes, Alt+1..9 tabs, Alt+z zoom, Alt+t new tab, Alt+s switcher
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
bind -n M-z resize-pane -Z
bind -n M-t new-window -c "#{pane_current_path}"
bind -n M-s choose-tree -Zs
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-6 select-window -t :=6
bind -n M-7 select-window -t :=7
bind -n M-8 select-window -t :=8
bind -n M-9 select-window -t :=9
# Shift+Enter in Claude Code needs extended keys passed through
set -s extended-keys on
set -as terminal-features ',*:extkeys'
# Copy mode with vi keys
setw -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# ========================================
# Status Bar Styling
# ========================================
# Status bar colors
set -g status-style bg=default,fg=white
# Left status bar: session name
set -g status-left-length 40
set -g status-left "#[fg=green,bold][#S] "
# Right status bar: date and time
set -g status-right "#[fg=yellow]Alt+m menu #[fg=cyan]%d %b %R"
# Window status
setw -g window-status-format "#[fg=white] #I:#W "
setw -g window-status-current-format "#[fg=black,bg=green,bold] #I:#W "
# Pane border colors
set -g pane-border-style fg=colour238
set -g pane-active-border-style fg=green
# Message colors
set -g message-style bg=black,fg=green,bold
# ========================================
# Ghostty Integration
# ========================================
# Don't interfere with Ghostty's clipboard
set -g set-clipboard on
# Fast escape time (better for vim/neovim in tmux)
set -sg escape-time 0
# Allow passthrough for Ghostty features
set -g allow-passthrough on
# ========================================
# Plugins (optional - uncomment if needed)
# ========================================
# Install TPM: git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# Then press Prefix + I to install plugins
# set -g @plugin 'tmux-plugins/tpm'
# set -g @plugin 'tmux-plugins/tmux-sensible'
# set -g @plugin 'tmux-plugins/tmux-resurrect'
# set -g @plugin 'tmux-plugins/tmux-continuum'
# Initialize TMUX plugin manager (keep this at the very bottom)
# run '~/.tmux/plugins/tpm/tpm'