kutsan / zsh-system-clipboard

System clipboard key bindings for Zsh Line Editor with vi mode. It is similar to what `set clipboard=unnamed` does for vim.
GNU General Public License v3.0
149 stars 16 forks source link

Better clipboard tool autodetection for linux/freebsd #45

Closed MahouShoujoMivutilde closed 2 years ago

MahouShoujoMivutilde commented 2 years ago

Old implementation relied on absence of $DISPLAY to detect Wayland. But $DISPLAY can be set even in Wayland session. I don't fully know why, I suspect it is because of XWayland.

So it won't pick correct tool.

This implementation relies on $WAYLAND_DISPLAY, which won't be set in Xorg session, and $XDG_SESSION_TYPE to detect wayland. It also checks if wl-clipboard is installed for consistency.

Additionally, it handles cases when there is no GUI running (SSH session, or TTY).

doronbehar commented 2 years ago

This is exactly the kind of over sophisticated logic I wanted to avoid when writing https://github.com/kutsan/zsh-system-clipboard/pull/43 . Do you have any problem using simply $ZSH_SYSTEM_CLIPBOARD_METHOD?

MahouShoujoMivutilde commented 2 years ago

I mean, I could, but you have this whole case here for autodetecting appropriate clipboard tool in case the variable is empty, and it currently fails do detect wayland on my wayland system. So I thought - hey, let me fix that.

Is it really that sophisticated? It just switches one variable for another. Everything else is just to make sure it won't run in ssh/tty, and too fairly short and simple.

doronbehar commented 2 years ago

I'm sorry but I'm not willing to make things more complex then they are now with all of these environment variables. I added wl-copy installed check in 4ed2721463f7e8496b92a62836c9ecb325ed023a .

MahouShoujoMivutilde commented 2 years ago

Okay, sure.

Btw, regarding your use case with ssh -Y... - I don't know if you know about about osc52, but it's a thing, and more appropriate for the use case like remote copy (doesn't expose the whole X server for the sake of copying text).

https://github.com/jirutka/tty-copy (written in C)

https://gist.github.com/carloseberhardt/d9433f308e31c3ffebc34d07da074e22 (shell)

Maybe you'll find those useful.