# ============================================================
# ~/.tmux.conf — Full pentest tmux config
# Theme: theme.nix (gruvpine) | Plugins: nixpkgs (modules/home/shell.nix)
# ============================================================
# ── Prefix ──────────────────────────────────────────────────
# Ctrl-b is prefix (tmux default). Ctrl-a is kitty's own prefix
# (modules/home/terminal.nix), which swallows it before tmux sees it.
set -g prefix C-b
unbind C-a
bind C-b send-prefix
# ── Terminal & Colors ────────────────────────────────────────
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc" # true colour
set -ga terminal-overrides "*:Ss=\E[%p1%d q:Se=\E[ q" # cursor shape
set -ag terminal-features "xterm-kitty:extkeys"
set -ag terminal-features ",alacritty:RGB"
set -as terminal-features ",*:clipboard"
set -g set-clipboard on
# ── General ──────────────────────────────────────────────────
set -g mouse on
set -g history-limit 50000
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
set -g escape-time 0 # no delay for Escape key (important for vim/nvim)
set -g focus-events on
set -g status-interval 5 # refresh status every 5s
# ── Vi mode ──────────────────────────────────────────────────
set -g mode-keys vi
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "wl-copy"
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi Escape send -X cancel
# Incremental search — live highlight + dim of non-matches as you type.
# The default "/"/"?" bindings use a non-interactive prompt (nothing happens
# until you press Enter), which is why they look broken. These replace them.
bind -T copy-mode-vi / command-prompt -i -I "#{pane_search_string}" -T search -p "(search down)" { send-keys -X search-forward-incremental -- "%%" }
bind -T copy-mode-vi ? command-prompt -i -I "#{pane_search_string}" -T search -p "(search up)" { send-keys -X search-backward-incremental -- "%%" }
# ── Splits & Windows ─────────────────────────────────────────
unbind %
unbind '"'
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# ── Pane Navigation (vim-style) ──────────────────────────────
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Pane resize with Shift+arrows
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 Reload ─────────────────────────────────────────────
bind r source-file ~/.tmux.conf \; display " Config reloaded!"
# ── Pentest-Specific Layouts ─────────────────────────────────
# prefix + P — launch pentest session layout
bind P run-shell "~/.dotfiles/scripts/htb-layout.sh"
# ── Smart Pane Switching (with awareness of vim/nvim) ────────
# Nix wraps the binary, so nvim runs as ".nvim-wrapped": allow the dot and suffix.
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?\\.?g?(view|n?vim?x?)(diff)?(-wrapped)?$'"
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# ── Activity Alerts ──────────────────────────────────────────
setw -g monitor-activity on
set -g visual-activity off # no message spam, just indicator in status
# ============================================================
# THEME — the palette theme.nix selects (gruvpine now)
# ============================================================
# ~/.config/tmux/palette.conf is written by NixDaemon modules/home/shell.nix from
# modules/_palette.nix and sets thm_bg, thm_fg, thm_surface0, thm_blue,
# thm_green, thm_red, thm_yellow, thm_mauve, thm_teal, thm_lavender.
# tmux expands ${thm_*} while parsing a file, before a source-file in it runs, so
# everything that uses the colours is in a second file, parsed after the palette:
# ~/.dotfiles/config/tmux-theme.conf (borders, messages, status bar, prefix
# highlight). It runs before the plugins: tmux-continuum hooks its autosave into
# status-right and tmux-prefix-highlight fills #{prefix_highlight}.
source-file ~/.config/tmux/palette.conf
source-file ~/.dotfiles/config/tmux-theme.conf
# ============================================================
# PLUGINS
# ============================================================
# Installed from nixpkgs by NixDaemon modules/home/shell.nix (a TPM stand-in
# runs them); the @plugin lines are documentation. Add a plugin there, not here.
# Session persistence — survives reboots (critical for Pro Labs)
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank' # better clipboard
set -g @plugin 'tmux-plugins/tmux-open' # open URLs from copy mode
set -g @plugin 'tmux-plugins/tmux-logging' # pane logs / screen captures as evidence
set -g @plugin 'laktak/extrakto' # fzf over pane text (hashes, IPs, paths)
set -g @plugin 'Morantron/tmux-fingers' # hint-copy IPs, hashes, URLs on screen
set -g @plugin 'sainnhe/tmux-fzf' # fzf menu: sessions, windows, panes, processes
set -g @plugin 'tmux-plugins/tmux-sessionist' # session keys: g C X S @ t
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# Resurrect/Continuum settings
set -g @resurrect-capture-pane-contents 'on' # save pane contents
set -g @resurrect-strategy-nvim 'session' # restore nvim sessions
set -g @continuum-restore 'off' # manual restore only (prefix + Ctrl-r)
set -g @continuum-save-interval '15' # save every 15 minutes
# tmux-yank settings
set -g @yank_selection_mouse 'clipboard'
set -g @override_copy_command 'wl-copy'
# tmux-logging — prefix O toggles logging this pane, M-o captures the screen,
# M-O saves the whole history, M-c clears it. (Its default P is the HTB layout.)
set -g @logging_key 'O'
set -g @screen-capture-key 'M-o'
set -g @save-complete-history-key 'M-O'
set -g @logging-path "$HOME/.pentest/logs"
set -g @screen-capture-path "$HOME/.pentest/logs"
set -g @save-complete-history-path "$HOME/.pentest/logs"
# extrakto — prefix Tab: fuzzy-pick a word/line/path from the pane; Tab inserts, Enter copies.
set -g @extrakto_clip_tool 'wl-copy'
set -g @extrakto_split_direction 'p' # popup
# tmux-fingers — prefix F: hint letters over IPs, hashes, URLs, paths; type to copy.
set -g @fingers-key F
set -g @fingers-pattern-0 '[0-9a-fA-F]{32}:[0-9a-fA-F]{32}' # LM:NT pairs
set -g @fingers-pattern-1 '\$[0-9a-z]+\$[^ ]+' # crypt hashes ($6$…, $krb5…)
# tmux-fzf — prefix C-f (F is fingers).
set-environment -g TMUX_FZF_LAUNCH_KEY 'C-f'
# ── Bootstrap TPM ────────────────────────────────────────────
run '~/.tmux/plugins/tpm/tpm'