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): improve OSC 52 escape sequence for SSH compatibility by Son0fSun · Pull Request #9008 · anomalyco/opencode

Conversation

@Son0fSun

@Son0fSun Son0fSun commented Jan 17, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Summary

  • Fix OSC 52 clipboard not working over SSH
  • Fix GNU Screen passthrough using wrong format
  • Add nested tmux session support
  • Use ST terminator instead of BEL for better compatibility

Problem

Clipboard copy operations fail when running OpenCode over SSH. The existing OSC 52 implementation had several issues:

  1. Used BEL (\x07) terminator which some terminals don't handle correctly inside DCS sequences
  2. Applied tmux-style passthrough (tmux; prefix) to GNU Screen, which uses a different format
  3. No support for nested tmux sessions

Fixes #6111
Fixes #2773

Solution

1. BEL → ST Terminator

- const osc52 = `\x1b]52;c;${base64}\x07`
+ const osc52 = `\x1b]52;c;${base64}\x1b\\`

ST (String Terminator) is more reliably handled inside DCS passthrough sequences.

2. Correct GNU Screen Format

// GNU Screen: DCS without tmux; prefix
const wrapped = osc52.replace(/\x1b/g, "\x1b\x1b")
sequence = `\x1bP${wrapped}\x1b\\`

3. Nested tmux Support

Detect nesting level from TMUX environment variable (comma-separated) and double escapes for each level:

const tmuxLevel = (process.env["TMUX"]?.match(/,/g) || []).length + 1
for (let i = 0; i < tmuxLevel; i++) {
  wrapped = wrapped.replace(/\x1b/g, "\x1b\x1b")
  wrapped = `\x1bPtmux;${wrapped}\x1b\\`
}

Supported Environments

Environment Status
iTerm2 ✅
Kitty ✅
Alacritty ✅
Windows Terminal ✅
tmux ✅
Nested tmux ✅
GNU Screen ✅

Test plan

  • Tested copy operation over SSH session
  • Verified paste works on local machine
  • Test inside tmux
  • Test inside GNU Screen
  • Test nested tmux (tmux inside tmux)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 [email protected]

Sorry, something went wrong.

Uh oh!

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

djdembeck reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Son0fSun @claude
fix(clipboard): improve OSC 52 escape sequence for SSH compatibility
8a1ce2e
Fix clipboard operations not working over SSH by improving the OSC 52
escape sequence implementation with proper terminal multiplexer support.

## Problems Fixed

1. **BEL vs ST terminator**: Changed from BEL (\x07) to ST (\x1b\\)
   for better compatibility. Some terminals don't handle BEL correctly
   inside DCS passthrough sequences.

2. **GNU Screen passthrough**: Fixed incorrect format - Screen uses
   DCS without the `tmux;` prefix that was being applied to both.
   - Before: `\x1bPtmux;\x1b<seq>\x1b\\` (wrong for Screen)
   - After: `\x1bP<seq>\x1b\\` (correct for Screen)

3. **Nested tmux sessions**: Added detection of tmux nesting level
   via comma count in TMUX env var, doubling escapes for each level.

## Technical Details

OSC 52 format: ESC ] 52 ; c ; <base64> ST

Passthrough wrapping:
- tmux: `ESC P tmux; ESC ESC <seq> ESC \`
- screen: `ESC P ESC ESC <seq> ESC \`

The escape characters must be doubled inside DCS sequences so they
pass through to the outer terminal emulator.

## Supported Terminals

- iTerm2, Kitty, Alacritty, Windows Terminal
- tmux (including nested sessions)
- GNU Screen
- Most modern terminal emulators

Fixes: anomalyco#6111
Fixes: anomalyco#2773

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

github-actions Bot commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

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

Based on my search, I found one potentially related PR:

PR #7028: fix(clipboard): add OSC 52 fallback for SSH/tmux environments
#7028

This PR appears to address similar issues with OSC 52 clipboard functionality in SSH and tmux environments. You should check if this PR was already merged or if it's still open, as it may cover some or all of the same fixes being proposed in PR #9008.

All reactions

Sorry, something went wrong.

Uh oh!

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

@b3nw

b3nw commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

this should be resolved in by #8974

All reactions

Sorry, something went wrong.

Uh oh!

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

@fcimeson

fcimeson commented Jan 17, 2026

Copy link
Copy Markdown

Can we just get an option to disable the clipboard outright so that we can use the normal right click copy and paste?

All reactions

Sorry, something went wrong.

Uh oh!

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

@b3nw

b3nw commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

that was built -> OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT
#4751

All reactions

Sorry, something went wrong.

Uh oh!

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

@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:50
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@ErcinDedeoglu ErcinDedeoglu mentioned this pull request Feb 3, 2026
OSC52 clipboard doesn't work with VS Code Remote SSH - need fallback or detection #11909
Closed
@github-actions github-actions Bot mentioned this pull request Feb 4, 2026
fix(clipboard): write OSC52 to /dev/tty instead of stdout #12129
Closed
4 tasks done
@github-actions github-actions Bot mentioned this pull request Feb 18, 2026
fix:solved the copy issue in TUI #14101
Closed
5 tasks done
@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
@github-actions

github-actions Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot closed this Mar 19, 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.

Copy to clipboard broken over SSH (MobaXterm & Windows Terminal) clipboard copy not works in remote SSH console.

Uh oh!

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

3 participants

@Son0fSun @b3nw @fcimeson
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.