Skip to content

feat: add osc52 support#76

Open
alsharifnahas wants to merge 1 commit into
atotto:masterfrom
alsharifnahas:master
Open

feat: add osc52 support#76
alsharifnahas wants to merge 1 commit into
atotto:masterfrom
alsharifnahas:master

Conversation

@alsharifnahas
Copy link
Copy Markdown

@alsharifnahas alsharifnahas commented Jul 26, 2025

This adds support for writing to clipboard via OSC52 only if an SSH session is active. Read support, if supported, is often blocked by terminals or prompted for security reasons. This PR only adds write support for simplicity. Read support, though more complicated, can be added in a separate PR since it requires reading the terminal for response in an asynchronous manner which can also affect TUI applications using this library.

Fixes: #73

Comment thread clipboard.go

import "os"

var isSsh = os.Getenv("SSH_TTY") != ""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditioning on SSH seems strange. I see how it narrowly focuses it on your case, but is there a better way to tell OSC-52 should be used?

@fzimmermann89
Copy link
Copy Markdown

I would also be interested in this feature (mainly for ssh work and within vscode terminal, specifically codegrab which uses this library).
Unfortunalty, I dont think there is a way to check if osc52 sequences "work". So either always fall back to them (and maybe silently fail) or explicitly enable them in the interface or environment variable.

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.

Improvement suggestion: add OSC52 as alternate method for copying to clipboard

3 participants