software-jessies-org / jessies

Terminator, Evergreen, lwm and friends
GNU General Public License v2.0
84 stars 19 forks source link

feature: support for setting local clipboard from remote terminal com… #49

Closed ssadedin closed 3 years ago

ssadedin commented 3 years ago

This pull request adds support for the OSC52 terminal command which allows a remote program to set the contents of the local system clipboard.

See:

https://jdhao.github.io/2021/01/05/nvim_copy_from_remote_via_osc52/

This can be really useful when you are working in a hybrid mode with a lot of transfer between a remote system and the local one.

This functionality is disabled by default, and a new option is added in preferences to enable it.

martindorey commented 3 years ago

Thanks for the feature and sorry for the lag. I did tat about it with a bit, initially because of the tabs and then because I failed to understand why the last character was being dropped and why that didn't break it (which I guess was base64 padding). If it wasn't the first time I've merged a git branch, then I've forgotten whatever I learned last time. Did I not destroy it all? /me dries off sweaty palms. I'd be more than happy to merge, or whatever's needed, if you wanted to write something for the docco about how you use it.

ssadedin commented 3 years ago

Thanks @martindorey! I had a go at some docs but got a bit stuck because I don't have access to edit the Wiki ... I cloned it and pushed the edits to my fork - but unlike the code repo I can't see a good way to turn it into a single-click pull request for you:

https://github.com/ssadedin/jessies/wiki/TerminatorManual#remote-clipboard-support

I think if you were to clone the wiki yourself locally and then add my version of it as a remote it would be possible to merge between them ... but if the merge process above stretched your comfort level with Git then I am guessing this will be far harder than manually editing in the same change on your end! Here is the literal Markdown I added if you just want to add it in manually:

## Remote Clipboard Support

Many users spend much time logged into remote systems and a lot of time working in a hybrid mode where part of the work
is happening locally and part is happening remotely, or alternatively, you may be working across two remote systems.
In such contexts it is quite frustrating that you can't easily have a clipboard that works across all of them without
manually selecting text. Fortunately ANSI defines escape sequences for manipulating the clipboard, and this means that
after enabling it in preferences, you can have all your sessions - whether remote or local - working with the
same clipboard contents. See [this blog post](https://jdhao.github.io/2021/01/05/nvim_copy_from_remote_via_osc52/) 
for some more information about how this is used and why it is useful. Please note that it is **disabled by default**
because some people perceive it as a security risk, and generally it would be wise not to have it enabled if you
are SSH'ing to hostile or untrusted servers, since they will be able to put literally anything into your clipboard
without you knowing.

Of course, if you give me access to edit the main Wiki I'll happily add this in myself :-)

martindorey commented 3 years ago

if the merge process above stretched your comfort level with Git

(Indeed it did, but it's a saleable skill, or it would be if I hadn't already forgotten, to the limited extent that I'd understood what I was doing anyway. I belatedly see that I didn't end up pushing the branch, but did end up pushing the changes in it, so my mental model of a branch is even more divergent from reality than I thought.)

this will be far harder than manually editing in the same change

Going into it with expectations thus set meant that I was pleasantly surprised. It was just a matter of cloning that then doing: git remote set-url origin git@github.com:software-jessies-org/jessies.wiki.git