GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(clipboard): write OSC52 to /dev/tty instead of stdout by alse-sym · Pull Request #12129 · anomalyco/opencode

Conversation

@alse-sym

@alse-sym alse-sym commented Feb 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aidan-gallagher, larsmoan, Crashel1, milanglacier, jekh, and lukdz reacted with thumbs up emoji
All reactions
  • 👍 6 reactions
@alse-sym @claude
fix(clipboard): write OSC52 to /dev/tty instead of stdout
01e4ebe
Fixes clipboard copy failing in terminal multiplexers like Zellij,
tmux, and screen. These tools intercept OSC52 escape sequences written
to stdout but do not forward them to the outer terminal.

Writing to /dev/tty (or SSH_TTY when connected via SSH) bypasses the
multiplexer's PTY layer and sends OSC52 directly to the terminal
emulator. Falls back to stdout if /dev/tty is unavailable (e.g., on
Windows).

Fixes anomalyco#12082

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

  • PR fix(clipboard): improve OSC 52 escape sequence for SSH compatibility #9008: "fix(clipboard): improve OSC 52 escape sequence for SSH compatibility"
    • URL: fix(clipboard): improve OSC 52 escape sequence for SSH compatibility #9008

This PR appears to address a related clipboard OSC52 issue with SSH compatibility. Since PR #12129 also handles SSH scenarios (using SSH_TTY environment variable) and deals with OSC52 clipboard operations, #9008 may be addressing the same or overlapping problem.

Recommendation: Check PR #9008 to determine if it's already solving this issue or if there are differences in approach (writing to /dev/tty vs other methods).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shrutsureja shrutsureja mentioned this pull request Feb 18, 2026
fix:solved the copy issue in TUI #14101
Closed
5 tasks done
@bnema bnema mentioned this pull request Feb 20, 2026
bug: OSC52 clipboard conflicts with Zellij auto-select-copy #14385
Closed
@bnema

bnema commented Feb 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Just wanted to flag that this PR also fixes a related issue with Zellij's auto-select-copy feature (see #14385).

When copy_on_select is enabled in Zellij, opencode's OSC52 writes to stdout conflict with Zellij's clipboard handling. Zellij intercepts the sequence but never forwards it to the outer terminal. Writing to /dev/tty as proposed here would bypass Zellij entirely and fix both problems at once.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aspiers

aspiers commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

I'm seeing this issue too. Would be great to have it fixed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aspiers aspiers mentioned this pull request Mar 2, 2026
[BUG] /share clipboard copy fails over SSH #9374
Closed
@github-actions github-actions Bot mentioned this pull request Mar 5, 2026
fix(opencode): tmux clipboard cannot copy to system clipboard #16195
Closed
3 of 6 tasks
@ls-aron-kyle

ls-aron-kyle commented Mar 10, 2026

Copy link
Copy Markdown

Also seeing this issue. When can we get a fix?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@milanglacier

milanglacier commented Mar 30, 2026

Copy link
Copy Markdown

This is a useful feature. Any blockers for not merging it?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alse-sym @claude
fix(clipboard): resolve merge conflict with upstream dev
5cfd0e3
Keep sync `fs` import for OSC52 /dev/tty writes; use `fs.promises.rm`
for async cleanup; add Filesystem/Process/which imports from upstream.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
rjshrjndrn added a commit to rjshrjndrn/pi.nvim that referenced this pull request Apr 2, 2026
@rjshrjndrn
fix: suppress DCS tmux passthrough for OpenCode clipboard OSC 52
2cd24e2
OpenCode's clipboard.ts checks process.env.TMUX || process.env.STY and,
when either is set, wraps its OSC 52 clipboard sequence in a DCS tmux
passthrough frame (\x1bPtmux;\x1b...\x1b\).

When OpenCode runs inside a Neovim terminal buffer that is itself inside
tmux, those env vars are inherited. Neovim's libvterm does not handle
the DCS frame cleanly: the nested \x1b]52;c;<base64> sequence gets
routed back to OpenCode's stdin where Bubble Tea parses the OSC start
(\x1b]) and leaves 52;c;<base64> as typed characters in the input area.

Setting TMUX="" and STY="" in the termopen env makes the JS falsy
check evaluate to false, so OpenCode emits a plain OSC 52 instead.
libvterm handles plain OSC 52 via its clipboard callback without writing
anything back to the child's stdin. OpenCode's native clipboard path
(wl-copy / xclip / xsel) is unaffected.

Upstream fix tracked at anomalyco/opencode#12129 (write OSC 52 to
/dev/tty instead of stdout) - still open as of 2026-04-02.
@harryalbert harryalbert mentioned this pull request Apr 16, 2026
Fix: notifications broken on Windows (writeFileSync /dev/tty) warpdotdev/opencode-warp#12
Merged
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
@github-actions github-actions Bot mentioned this pull request May 9, 2026
fix(cli): handle OSC52 clipboard passthrough properly under gnu screen #26492
Closed
3 of 6 tasks
@github-actions github-actions Bot mentioned this pull request May 19, 2026
fix(opencode): remove double-ESC byte in tmux DCS passthrough for OSC 52 #28369
Closed
3 tasks done
@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
fix(tui): support copying over ssh with set-clipboard on tmux config #30472
Merged
3 of 6 tasks
@github-actions github-actions Bot mentioned this pull request Jul 4, 2026
fix(tui): flush OSC 52 clipboard write, propagate errors on fallback #35289
Closed
3 tasks done
@github-actions github-actions Bot mentioned this pull request Aug 23, 2026
fix(tui): clipboard copy on Linux without external binaries #44394
Closed
3 of 6 tasks
@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr thdxr closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Clipboard copy fails in Zellij and other multiplexers (OSC52 written to stdout instead of /dev/tty)

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@alse-sym @bnema @aspiers @ls-aron-kyle @milanglacier @thdxr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.