[PR #12129] fix(clipboard): write OSC52 to /dev/tty instead of stdout #14079

Open
opened 2026-02-16 18:18:53 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12129

State: open
Merged: No


Summary

  • Write OSC52 escape sequences to /dev/tty instead of stdout to bypass terminal multiplexers
  • Use SSH_TTY environment variable when connected via SSH
  • Fall back to stdout when /dev/tty is unavailable (e.g., Windows)

Problem

Clipboard copy fails in terminal multiplexers (Zellij, tmux, screen) because they intercept OSC52 sequences written to stdout and don't pass them through to the outer terminal.

Solution

Write directly to /dev/tty which bypasses the multiplexer's PTY layer. This is how tools like lazygit and neovim handle clipboard operations in multiplexers.

Fixes #12082

Test plan

  • Test clipboard copy in Zellij
  • Test clipboard copy in tmux
  • Test clipboard copy outside multiplexers (direct terminal)
  • Test clipboard copy over SSH

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12129 **State:** open **Merged:** No --- ## Summary - Write OSC52 escape sequences to `/dev/tty` instead of `stdout` to bypass terminal multiplexers - Use `SSH_TTY` environment variable when connected via SSH - Fall back to stdout when `/dev/tty` is unavailable (e.g., Windows) ## Problem Clipboard copy fails in terminal multiplexers (Zellij, tmux, screen) because they intercept OSC52 sequences written to stdout and don't pass them through to the outer terminal. ## Solution Write directly to `/dev/tty` which bypasses the multiplexer's PTY layer. This is how tools like lazygit and neovim handle clipboard operations in multiplexers. Fixes #12082 ## Test plan - [ ] Test clipboard copy in Zellij - [ ] Test clipboard copy in tmux - [ ] Test clipboard copy outside multiplexers (direct terminal) - [ ] Test clipboard copy over SSH 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-16 18:18:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14079