-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Set-Clipboard -Remote with OSC52 #18116
Copy link
Copy link
Closed
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Metadata
Metadata
Assignees
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Summary of the new feature / enhancement
Set-Clipboarddoes not really work over SSH, as it always sets the clipboard of the target machine, not the host. This means that if you SSH e.g. from your PC to a server, thenSet-Clipboardwill set the server's clipboard, not your PCs, so you cannot paste it anywhere.This can be resolved by using ANSI escape sequence (same mechanism as for setting colors) OSC52, which sets the clipboard of the host machine, which in our example is the PC, so you can paste it anywhere. This sequence is supported by most terminals, including Microsoft Terminal.
Example:
OSC also has similar
Get-Clipboard -Remotesequence, but no terminal implements it as it is rightly considered a security and privacy risk, and you ca simply "get" the host clipboard with Ctrl+Shift+V.Opens:
$env:SSH_CLIENTand$env:SSH_TTY. I would say no, as it could be potentially breaking behavior in case of false positives on terminals which don't support the OSC. If user wants such behavior, they can add$PSDefaultParameters['Set-Clipboard:Remote'] = $env:SSH_CLIENT -or $env:SSH_TTYto their$PROFILE.set -s set-clipboard on. I would say keep it simple for now, then maybe add-RemoteMethod = auto | osc52 | tmux | screenin separate issue if required.Proposed technical implementation details (optional)
See example for the escape sequence format.