# --- Basics ---------------------------------------------------------------
set -g history-limit 100000 # Large scrollback so snapshots have depth
set -g xterm-keys on # Enable extended keys (Alt+Arrows, etc.)
set -g mode-keys vi # Vi-style keys in copy/selection mode
set -g set-clipboard on # Integrate with system clipboard (if supported)
# --- Copy / word navigation ----------------------------------------------
unbind -T copy-mode-vi C-c
bind-key -T copy-mode-vi C-c send -X copy-selection
# Word-wise movement with Alt+Left/Right in the pane and in copy modes
bind -n M-Left send-keys M-b # Back one word (pane)
bind -n M-Right send-keys M-f # Forward one word (pane)
bind -T copy-mode-vi M-Left send -X previous-word
bind -T copy-mode-vi M-Right send -X next-word
bind -T copy-mode M-Left send -X previous-word
bind -T copy-mode M-Right send -X next-word
# Prevent copy and paste errors inside vim
set -s escape-time 0
# --- Logging ---------------------------------------------------------------
set -g @log_root "$HOME/tmuxlogs"
set -g @log_cmd 'sh -lc "mkdir -p #{q:@log_root}/#{q:session_name}; exec awk '"'"'{print; fflush()}'"'"' >> #{q:@log_root}/#{q:session_name}/#{window_index}.#{pane_index}-$(date +%m_%d_%Y_%H_%M_%S).log"'
# Auto-start logging for new sessions, windows, and splits (target = current pane)
set-hook -g after-new-session 'pipe-pane -o "#{E:@log_cmd}"'
set-hook -g after-new-window 'pipe-pane -o "#{E:@log_cmd}"'
set-hook -g after-split-window 'pipe-pane -o "#{E:@log_cmd}"'