helix icon indicating copy to clipboard operation
helix copied to clipboard

Enable OSC52 automatically if connected via SSH

Open jonas-w opened this issue 1 year ago • 3 comments
trafficstars

When connecting via ssh to a macOS host, helix still uses pbcopy+pbpaste as a clipboard provider instead of OSC52. I think this is not a problem when the remote is a Linux host, as helix checks for WAYLAND_DISPLAY/DISPLAY environment variables, which are normally not set in an SSH session. (at least I never had problems with Linux remotes)

My enhancement would be to check for the $SSH_CONNECTION environment variable, and if this is set, it would use the FallbackProvider instead of pbcopy+pbpaste. As I mentioned before, this seems to be only a problem if the remote is macOS, so it would probably be suffice to add this check to the macOS target of the get_clipboard_provider method.

jonas-w avatar Jun 28 '24 11:06 jonas-w

I'd also be willing to open a PR for this.

jonas-w avatar Jul 01 '24 11:07 jonas-w

I'd be willing to test and confirm said PR.

jpeeler avatar Jul 27 '24 21:07 jpeeler

Yes this seems to work just fine in Linux. No Wayland specific environment variables are passed via SSH and "+y will copy text to the system clipboard.

hholst80 avatar Aug 25 '24 12:08 hholst80

I spent couple of hours trying to get OSC52 working from Ubuntu over SSH from my mac iterm2. It works fine in terminal using: printf '\e]52;c;dGVzdA==\a'

This is just a wrap of Base64 string, using OSC 52 escape sequence: \e]52;c;BASE64_TEXT\a. \e] : Starts an OSC sequence. 52 : Identifies it as the clipboard command. ;c; : Specifies the "clipboard" selection (other selections exist but 'c' is standard clipboard). BASE64_TEXT : The Base64 encoded version of the text you want to copy. \a : The "Bell" character, used to terminate the sequence.

So it workes from the server to my client, but I cant get hx to output this when i yank to system clipboard.

JonSpeare avatar Apr 05 '25 21:04 JonSpeare