# 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" # ===== Clipboard: every yank goes to both places, neither blocks; prefix ] tries remote, then local ===== # local: pbcopy on Mac, OSC 52 (set-clipboard on) everywhere; remote: RAM file /dev/shm/clip/buf on CLIP_HOST; copy-pipe runs as a background job %hidden CLIP_HOST="root@p.noml.ch" %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" %hidden YANK="f=\$(mktemp); cat >\$f; pbcopy <\$f 2>/dev/null; $CLIP 'umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf' <\$f >/dev/null 2>&1; rm -f \$f" 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" # prefix + ] pastes remote buffer; any remote failure or >3 s = Mac clipboard (Linux: tmux buffer); -b keeps tmux responsive meanwhile bind-key ] run-shell -b "f=\$(mktemp); perl -e 'alarm 3; exec @ARGV' $CLIP '[ -f /dev/shm/clip/buf ] || exit 3; cat /dev/shm/clip/buf' >\$f 2>/dev/null || pbpaste >\$f 2>/dev/null || tmux save-buffer \$f; tmux load-buffer \$f; rm -f \$f; tmux paste-buffer -p -t '#{pane_id}'" # ===== end 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" }