# Ctrl-b f: prompt for text, list windows whose name, pane title or pane contents match; Enter jumps # Ctrl-b w: tree of every window in every session; press f inside it to filter by name, Enter jumps # Ctrl-b s: tree of sessions (same tree, session view) # Ctrl-b p: go to the previous window (lower index, wraps); Ctrl-b n goes to the next one # # Vi mode for copy setw -g mode-keys vi # Mouse selection set -g mouse on # Scrollback lines per pane (new panes only; a full pane is ~5-10 MB, memory is only used as it fills) set -g history-limit 10000 # Persistent pane index labels (top-left of each pane's border) set -g pane-border-status top set -g pane-border-format "#P" # Swap current pane with pane N: prefix S then N (same number overlay as prefix q) bind-key S display-panes { swap-pane -d -t '%%' } # Manual: :swap-pane -s -t # Go to pane N: prefix q then N (numbers stay up 3 s; pressing the digit ends it early) set -g display-panes-time 3000 # Vim-style pane resizing (prefix + H/J/K/L), magnitude 1 bind -r H resize-pane -L 1 bind -r J resize-pane -D 1 bind -r K resize-pane -U 1 bind -r L resize-pane -R 1 # Copy-mode cursor line (counted up from the bottom, matches the : goto-line prompt) in the status line; # the status bar redraws every second, the top-right copy-mode indicator does not follow the cursor # : goto-line only scrolls the view; also put the cursor on the bottom row so the status line shows the typed number bind-key -T copy-mode-vi : command-prompt -p "(goto line)" { send-keys -X goto-line "%%" ; send-keys -X bottom-line } set -g status-interval 1 set -g status-right-length 70 set -g status-right "#{?pane_in_mode,line #{e|+:#{scroll_position},#{e|-:#{e|-:#{pane_height},1},#{copy_cursor_y}}}/#{history_size} ,}\"#{=21:pane_title}\" %H:%M %d-%b-%y" # prefix + /: whole scrollback in a read-only vim popup with line numbers (:N, /search, y); :q closes it # (replaces the default prefix + / "describe key"); capture goes via a named buffer so it targets this pane bind-key / capture-pane -J -S - -b scrollback \; display-popup -E -w 99% -h 99% "f=\$(mktemp); tmux save-buffer -b scrollback \$f; tmux delete-buffer -b scrollback; vim -M -c 'set number' + \$f; rm -f \$f" # ===== Shared clipboard: RAM file /dev/shm/clip/buf on CLIP_HOST ===== %hidden CLIP_HOST="root@p.noml.ch" # One persistent ssh link (opens on first use, one key touch). # Close it: ssh -O exit -o ControlPath=~/.ssh/cm-%C %hidden CLIP="ssh -o ControlMaster=auto -o ControlPersist=yes -o ControlPath=~/.ssh/cm-%C -o ServerAliveInterval=30 -o ConnectTimeout=3 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR $CLIP_HOST" # push (yank): copy mode v to select, then y / Enter / mouse drag %hidden YANK="$CLIP 'umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf'" bind-key -T copy-mode-vi v send-keys -X begin-selection # y = yank selection; with no selection, y y = yank the whole line bind-key -T copy-mode-vi y if-shell -F '#{selection_present}' { send-keys -X copy-pipe-no-clear "$YANK" } { switch-client -T copy-yy } bind-key -T copy-yy y send-keys -X select-line \; send-keys -X copy-pipe-no-clear "$YANK" bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "$YANK" bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "$YANK" # pull (paste): prefix + ] fetches the buffer into tmux, then pastes it (-p: bracketed paste, so vim inserts it as-is even from normal mode); # no buffer on CLIP_HOST yet (exit 3, e.g. after its reboot) = paste tmux's own buffer bind-key ] run-shell "f=\$(mktemp); $CLIP '[ -f /dev/shm/clip/buf ] || exit 3; cat /dev/shm/clip/buf' >\$f; r=\$?; [ \$r -eq 0 ] && tmux load-buffer \$f; rm -f \$f; [ \$r -eq 0 ] || [ \$r -eq 3 ] && tmux paste-buffer -p" # ===== end shared clipboard ===== # OSC 52: copy-mode yanks also go to the clipboard of the terminal you type in; "on" (not "external") # also forwards OSC 52 that vim writes inside a pane set -g set-clipboard on # Linux only: true-color regardless of what TERM the outer terminal/distro sets if-shell 'uname | grep -q Darwin' {} { set -g default-terminal "tmux-256color" set -ga terminal-overrides ",*256col*:Tc" }