Comment on I don't like the Linux clipboard situation

PhilipTheBucket@ponder.cat ⁨2⁩ ⁨weeks⁩ ago

Okay, if anyone is curious: I finally lost so much patience with all of this that I fought with it until it was actually doing what I want. It took far longer than it should have.

Here was the secret sauce, for my setup at least:

Wayland needs running in the background:

wl-paste -w sh -c 'wl-copy -p'

So what that does is send anything from CLIPBOARD to PRIMARY, so I can click “copy to clipboard” on a web page and still middle-click to paste it. I actually don’t care as much about the other way (which is good because it seems like it might cause an infinite loop); @Riskable@programming.dev you can rest easy that the Ctrl-V buffer won’t be affected by highlighting text and I can still do paste of whatever I wanted to, even if I highlighted in the middle.

Then in Helix config on any remote machine, have:

[editor]
clipboard-provider = "termcode"

That’s what enables us to highlight text in Helix and have it make it back to the local system’s clipboard. I actually don’t know which clipboard it’s going into there, and thanks to wl-paste, I don’t have to care.

Then, in kitty config on the local system, have:

mouse_map middle press ungrabbed paste_from_selection
mouse_map middle press grabbed paste_from_selection
mouse_map middle release ungrabbed discard_event
mouse_map middle release grabbed discard_event

That means that we disable all efforts which Helix will make to grab the middle-click event and fuck it up in some way or other. Kitty pastes the text, Helix receives it, and we have the nice side benefit that it goes in where the cursor is instead of at whatever random position I have let the pointer wander over to before I did the middle click.

Hallelujah. I can get back to actual work. Boy this wasn’t a big extensive confusing waste of time involving extra difficulty that didn’t need to be there. Great. Great.

source
Sort:hotnewtop