Files
nixos-config/home/common/programs/tmux.conf
T
Miguel Palhas d417a27f2d
CI / lint (push) Successful in 31s
CI / eval (push) Successful in 2m1s
feat: make the clipboard work across tmux, ssh and hosts
tmux copy bindings piped to xclip, which is X11-only and never worked
under Hyprland or over SSH, and set-clipboard was never enabled, so the
vi-mode `y` binding was dead too. Route both through OSC 52 instead.
terminal-features has to name the outer terminal explicitly: tmux skips
OSC 52 silently when the terminfo entry does not claim the capability,
which is the common case for an SSH session on xterm-256color.

Neovim only falls back to OSC 52 when it finds no clipboard tool, but
wl-clipboard is installed on every host, so over SSH it wrote the remote
clipboard. Pin the OSC 52 provider for SSH sessions only.

Moonlight and Sunshine have no clipboard channel in the protocol, so
nothing at the terminal layer can help there. Add kdeconnect on all three
hosts for that, and start its indicator from Hyprland — kdeconnectd is
DBus-activated and nothing else brings it up at login.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 08:14:17 +01:00

165 lines
5.2 KiB
Bash

# 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
# -------------------------------------------------------------------
# Clipboard (OSC 52)
# -------------------------------------------------------------------
set -g set-clipboard on
# tmux silently skips OSC 52 unless the outer terminal's terminfo claims the
# capability. kitty's does; SSH sessions usually land on a bare
# xterm-256color that does not, so declare both.
set -ag terminal-features ",xterm-kitty:clipboard"
set -ag terminal-features ",xterm-256color:clipboard"
# Let nvim's OSC 52 provider reach the outer terminal through tmux.
set -g allow-passthrough on
# 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). No external command: set-clipboard
# above routes this through OSC 52, which works on Wayland and over SSH.
# xclip did neither.
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel
# End agent-deck configuration