Skip to content

Comments

fix(tmux): use native OSC 52 for SSH clipboard copy#71

Merged
paveg merged 1 commit intomainfrom
fix/tmux-ssh-copy-mode
Feb 16, 2026
Merged

fix(tmux): use native OSC 52 for SSH clipboard copy#71
paveg merged 1 commit intomainfrom
fix/tmux-ssh-copy-mode

Conversation

@paveg
Copy link
Owner

@paveg paveg commented Feb 16, 2026

Summary

  • Replace manual base64 | xargs printf OSC 52 pipeline with copy-selection-and-cancel for SSH sessions
  • Rely on tmux's native OSC 52 mechanism (set-clipboard external + terminal-features clipboard) which correctly handles encoding and delivery
  • Fixes broken clipboard copy in PASSTHROUGH mode on EC2 (nested tmux over SSH)

Root cause

Linux base64 wraps output at 76 chars by default. xargs -I {} processed each line separately, generating multiple incomplete OSC 52 sequences. Additionally, /dev/tty may be unavailable in tmux server's daemonized copy-pipe subprocess.

Test plan

  • SSH into EC2, enter nested tmux (F12 PASSTHROUGH mode)
  • Select text in copy mode, press y — verify text lands in local clipboard
  • Test with short (<57 chars) and long (>57 chars) selections
  • Verify mouse drag copy (MouseDragEnd1Pane) also works
  • Verify local (non-SSH) pbcopy path is unaffected

…64 pipe

The manual base64 | xargs printf pipeline broke clipboard copy on remote
tmux sessions because Linux base64 wraps at 76 chars, causing xargs to
generate multiple incomplete OSC 52 sequences. Additionally, /dev/tty may
not be available in tmux server's daemonized copy-pipe subprocess.

Replace with copy-selection-and-cancel and rely on tmux's native OSC 52
mechanism (set-clipboard external + terminal-features clipboard) which
handles encoding and delivery correctly.
@paveg paveg merged commit f3cfdf2 into main Feb 16, 2026
8 checks passed
@paveg paveg deleted the fix/tmux-ssh-copy-mode branch February 16, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant