diff --git a/home/common/programs/tmux.conf b/home/common/programs/tmux.conf new file mode 100644 index 0000000..d0deef9 --- /dev/null +++ b/home/common/programs/tmux.conf @@ -0,0 +1,148 @@ +# Set prefix to Ctrl-a (more ergonomic than Ctrl-b) +set -g prefix C-a +unbind C-b +bind C-a send-prefix + +# Enable mouse support +set -g mouse on + +# 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 +set -g history-limit 50000 + +# Low escape-time (0 breaks Alt keys over SSH; 25ms is a good balance) +set -s escape-time 25 + +# Enable 256 colors +set -g default-terminal "tmux-256color" +set -ag terminal-overrides ",xterm-256color:RGB" + +# ------------------------------------------------------------------- +# Status bar theme +# ------------------------------------------------------------------- +set -g status-position bottom +set -g status-interval 5 +set -g status-style "bg=#1a1b26,fg=#a9b1d6" + +# Left: session name +set -g status-left-length 30 +set -g status-left "#[fg=#1a1b26,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#1a1b26,nobold] " + +# Right: continuum status + time +set -g status-right-length 50 +set -g status-right "#[fg=#565f89] #{?client_prefix,#[fg=#e0af68]PREFIX ,}#[fg=#565f89,bg=#1a1b26] %H:%M #[fg=#1a1b26,bg=#7aa2f7,bold] %d %b " + +# Window tabs +set -g window-status-format "#[fg=#565f89] #I #W " +set -g window-status-current-format "#[fg=#7aa2f7,bg=#24283b,bold] #I #W #[fg=#24283b,bg=#1a1b26]" +set -g window-status-separator "" + +# Pane borders +set -g pane-border-style "fg=#3b4261" +set -g pane-active-border-style "fg=#7aa2f7" + +# Message style +set -g message-style "fg=#7aa2f7,bg=#1a1b26,bold" +set -g message-command-style "fg=#7aa2f7,bg=#1a1b26" + +# Copy mode +setw -g mode-style "fg=#1a1b26,bg=#7aa2f7" + +# Easy config reload +bind r source-file ~/.tmux.conf \; display "Config reloaded!" + +# Better pane splitting (use current path) +bind \\ split-window -h -c "#{pane_current_path}" +bind - split-window -v -c "#{pane_current_path}" +unbind '"' +unbind % + +# New window in current path +bind c new-window -c "#{pane_current_path}" + +# Pane resize (if you ever use tmux panes) +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 switching (prefix + number) +bind 1 select-window -t 1 +bind 2 select-window -t 2 +bind 3 select-window -t 3 +bind 4 select-window -t 4 +bind 5 select-window -t 5 +bind 6 select-window -t 6 +bind 7 select-window -t 7 +bind 8 select-window -t 8 +bind 9 select-window -t 9 + +# Window navigation (prefix + h/l) +bind h previous-window +bind l next-window + +# Session navigation (prefix + j/k/S) +bind j switch-client -n # next session +bind k switch-client -p # previous session +bind S choose-tree -sZ # session tree picker + +# Move windows left/right +bind -r < swap-window -t -1\; select-window -t -1 +bind -r > swap-window -t +1\; select-window -t +1 + +# Enable vi mode for copy +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 + + +# tmux-resurrect settings +set -g @resurrect-capture-pane-contents 'on' +set -g @resurrect-strategy-nvim 'session' + +# tmux-continuum settings (auto-save and auto-restore) +set -g @continuum-restore 'on' +set -g @continuum-save-interval '10' + + +# agent-deck configuration +# agent-deck-tmux-config-version: 3 +# Added by agent-deck installer - 2026-03-18 +# https://github.com/asheshgoplani/agent-deck + +# Terminal with true color support +set -g default-terminal "tmux-256color" +set -ag terminal-overrides ",xterm*:Tc:smcup@:rmcup@" +set -ag terminal-overrides ",*256col*:Tc" + +# Performance +set -sg escape-time 0 +set -g history-limit 50000 + +# Extended keys: forward Shift+Enter and other modified keys to apps (tmux 3.2+) +set -s extended-keys on +set -as terminal-features 'tmux-256color:extkeys' + +# Mouse support (scroll + drag-to-copy) +set -g mouse on + +# Auto-enter copy-mode when scrolling up (critical for WSL compatibility) +# This handles: 1) apps with mouse support, 2) already in copy-mode, 3) normal pane +bind-key -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'" + +# Scroll bindings in copy-mode (both vi and emacs modes) +bind-key -T copy-mode-vi WheelUpPane send-keys -X scroll-up +bind-key -T copy-mode-vi WheelDownPane send-keys -X scroll-down +bind-key -T copy-mode WheelUpPane send-keys -X scroll-up +bind-key -T copy-mode WheelDownPane send-keys -X scroll-down + +# Clipboard integration (drag-to-copy) +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard" +bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard" +# End agent-deck configuration diff --git a/home/common/programs/tmux.nix b/home/common/programs/tmux.nix index 8015032..b97d4f3 100644 --- a/home/common/programs/tmux.nix +++ b/home/common/programs/tmux.nix @@ -1,5 +1,17 @@ +{ pkgs, ... }: { programs.tmux = { enable = true; + + # The @plugin lines and the tpm bootstrap are stripped from tmux.conf: + # home-manager writes the run-shell lines for these itself, and tpm would + # otherwise try to git-clone them into ~/.tmux/plugins at runtime. + plugins = with pkgs.tmuxPlugins; [ + sensible + resurrect + continuum + ]; + + extraConfig = builtins.readFile ./tmux.conf; }; }