Fix corruption in copy-paste over nested tmux

This commit is contained in:
2026-07-18 16:03:19 -07:00
parent ea5a2b77d4
commit efd1ddebd9
+9 -8
View File
@@ -60,14 +60,15 @@ bind C-y run 'tmux save-buffer - | $HOME/dotfiles/bin/clipboard-copy'
# option, so only set it when the running tmux is new enough.
if-shell "tmux -V | awk '{print $2}' | awk -F. '{if ($1*1000+$2 >= 3003) exit 0; else exit 1}'" 'set -g allow-passthrough on'
# Let tmux tell Shift+Enter apart from plain Enter and forward that
# distinction inward, so Claude Code's Shift+Enter-inserts-newline shortcut
# works. extended-keys/terminal-features need tmux >= 3.2. The terminal
# name is matched with '*' rather than the commonly-suggested 'xterm*',
# because a nested tmux's "terminal" is the outer tmux, which reports
# itself using default-terminal above (screen-256color) -- 'xterm*' would
# never match that, breaking the nested case this is meant to support.
if-shell "tmux -V | awk '{print $2}' | awk -F. '{if ($1*1000+$2 >= 3002) exit 0; else exit 1}'" 'set -s extended-keys on; set -as terminal-features "*:extkeys"'
# Deliberately OFF, do not re-enable: extended-keys makes tmux re-encode raw
# control-equivalent bytes (Tab, CR, Backspace, Escape, and LF/Ctrl-J) into
# CSI 27;<mod>;<key>~ sequences instead of passing the plain byte through,
# any time it doesn't recognize the data as bracketed paste. Turning this on
# previously mangled every LF byte -- both literal Ctrl+J keypresses and
# every newline in pasted text -- into that unrecognized CSI sequence before
# it reached the app in the pane, breaking Ctrl+J-as-newline and corrupting
# multi-line pastes with literal escape-sequence garbage.
set -s extended-keys off
# Accept pane-originated OSC 52 clipboard-set attempts into a real tmux
# buffer. Only on-vs-off matters here -- off would refuse to even look at