diff options
| author | xs <xs@xs.local> | 2026-11-07 19:12:56 +0800 |
|---|---|---|
| committer | xs <xs@xs.local> | 2026-11-07 19:12:56 +0800 |
| commit | 146066e5804e53a359c5aa5b71e8d774e3f54000 (patch) | |
| tree | 43097bf89cd1b257bde42be07db4df7637b2d0da /core | |
| parent | 779a43bf7004e824ded0d0fa024b577930da4c82 (diff) | |
tmux: copy-mode cursor line in status bar, : goto-line lands cursor, go-to-pane bind, yy yank line
Diffstat (limited to 'core')
| -rw-r--r-- | core/tmux.conf | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/core/tmux.conf b/core/tmux.conf index 2a0e161..d0d3ef8 100644 --- a/core/tmux.conf +++ b/core/tmux.conf | |||
| @@ -14,7 +14,8 @@ set -g pane-border-status top | |||
| 14 | set -g pane-border-format "#P" | 14 | set -g pane-border-format "#P" |
| 15 | 15 | ||
| 16 | # Explicitly swap current pane with a pane index you type in | 16 | # Explicitly swap current pane with a pane index you type in |
| 17 | bind-key P command-prompt -p "swap with pane #:" "swap-pane -d -t '%%'" | 17 | bind-key S command-prompt -p "swap with pane #:" "swap-pane -d -t '%%'" |
| 18 | bind-key P command-prompt -p "go to pane #:" "select-pane -t '%%'" | ||
| 18 | # Manual: :swap-pane -s <src> -t <dst> | 19 | # Manual: :swap-pane -s <src> -t <dst> |
| 19 | 20 | ||
| 20 | # Vim-style pane resizing (prefix + H/J/K/L), magnitude 1 | 21 | # Vim-style pane resizing (prefix + H/J/K/L), magnitude 1 |
| @@ -23,6 +24,14 @@ bind -r J resize-pane -D 1 | |||
| 23 | bind -r K resize-pane -U 1 | 24 | bind -r K resize-pane -U 1 |
| 24 | bind -r L resize-pane -R 1 | 25 | bind -r L resize-pane -R 1 |
| 25 | 26 | ||
| 27 | # Copy-mode cursor line (counted up from the bottom, matches the : goto-line prompt) in the status line; | ||
| 28 | # the status bar redraws every second, the top-right copy-mode indicator does not follow the cursor | ||
| 29 | # : goto-line only scrolls the view; also put the cursor on the bottom row so the status line shows the typed number | ||
| 30 | bind-key -T copy-mode-vi : command-prompt -p "(goto line)" { send-keys -X goto-line "%%" ; send-keys -X bottom-line } | ||
| 31 | set -g status-interval 1 | ||
| 32 | set -g status-right-length 70 | ||
| 33 | 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" | ||
| 34 | |||
| 26 | # ===== Shared clipboard: RAM file /dev/shm/clip/buf on CLIP_HOST ===== | 35 | # ===== Shared clipboard: RAM file /dev/shm/clip/buf on CLIP_HOST ===== |
| 27 | %hidden CLIP_HOST="root@p.noml.ch" | 36 | %hidden CLIP_HOST="root@p.noml.ch" |
| 28 | # One persistent ssh link (opens on first use, one key touch). | 37 | # One persistent ssh link (opens on first use, one key touch). |
| @@ -31,13 +40,16 @@ bind -r L resize-pane -R 1 | |||
| 31 | # push (yank): copy mode v to select, then y / Enter / mouse drag | 40 | # push (yank): copy mode v to select, then y / Enter / mouse drag |
| 32 | %hidden YANK="$CLIP 'umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf'" | 41 | %hidden YANK="$CLIP 'umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf'" |
| 33 | bind-key -T copy-mode-vi v send-keys -X begin-selection | 42 | bind-key -T copy-mode-vi v send-keys -X begin-selection |
| 34 | bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "$YANK" | 43 | # y = yank selection; with no selection, y y = yank the whole line |
| 44 | 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 } | ||
| 45 | bind-key -T copy-yy y send-keys -X select-line \; send-keys -X copy-pipe-no-clear "$YANK" | ||
| 35 | bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "$YANK" | 46 | bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "$YANK" |
| 36 | bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "$YANK" | 47 | bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "$YANK" |
| 37 | # pull (paste): prefix + ] fetches the buffer into tmux, then pastes it; | 48 | # pull (paste): prefix + ] fetches the buffer into tmux, then pastes it; |
| 38 | # no buffer on CLIP_HOST yet (exit 3, e.g. after its reboot) = paste tmux's own buffer | 49 | # no buffer on CLIP_HOST yet (exit 3, e.g. after its reboot) = paste tmux's own buffer |
| 39 | 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" | 50 | 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" |
| 40 | # ===== end shared clipboard ===== | 51 | # ===== end shared clipboard ===== |
| 52 | # TODO: try `set -g set-clipboard off` later (tmux default "external" sends copies to the local terminal clipboard via OSC 52); unrelated to the shared clipboard above | ||
| 41 | 53 | ||
| 42 | # Linux only: true-color regardless of what TERM the outer terminal/distro sets | 54 | # Linux only: true-color regardless of what TERM the outer terminal/distro sets |
| 43 | if-shell 'uname | grep -q Darwin' {} { | 55 | if-shell 'uname | grep -q Darwin' {} { |
