tmux-plugins / tmux-yank

Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin.
https://tmux-plugins.github.io/tmux-yank/
MIT License
2.71k stars 122 forks source link

yank to clipboard using xsel doesn't work #126

Open hensz opened 5 years ago

hensz commented 5 years ago

Hi! I run tmux with tmux-yank via x-forwarding on Windows, don't know if this is related. At least using xsel works fine: echo "foo" | xsel -b results in having "foo" in the system clipboard, accessible both from Linux and Windows.

However when copying from tmux by either using the mouse (with mouse-mode on) or by using the copy mode, the selection is always put in the PRIMARY clipboard, where I can paste it by using + ].

I tried using @override_copy_command or custom_copy_command, setting both to xsel -b, but with no effect. Also I set yank_selection_mouse to clipboard, which also has no effect. Am I doing something wrong?

Thanks, Torsten

wizonesolutions commented 5 years ago

@hensz Have you found a workaround for this? I can work around it by pressing y while holding the mouse button down, but it's annoying to hold the mouse button down. But disabling auto-yank on mouseup doesn't work either...it ignores the setting.

hensz commented 5 years ago

Hi! The workaround I currently use is holding SHIFT while selection - this disables tmux copy mode and uses the regular Linux copy mode. I can live with this, however I still want to know why the way I want to use doesn't work. Is this a bug, or am I doing somethign wrong here?

ebkalderon commented 5 years ago

Another user chiming in. It doesn't seem to work with xclip either. I can confirm that the workaround by @hensz works on my machine too, but at that point, there is no reason to use tmux-yank. For context, I'm running a very recent Arch Linux with tmux version 2.9a.

CollinChaffin commented 5 years ago

Same here. Running PhotonOS v3 which doesn't support xclip, xsel, or pbcopy so was hoping the ESC sequences (which I thought was the original magic behind this) would be my one option. Alas, this plugin still does not transfer anything to the clipboard.

hensz commented 5 years ago

Hi there! Does no one have any clue what causes the issue? Since tmux-yank explicitly supports pasting to the system clipboard it should be possible to get it to work - but how, with which settings? Any help is appreciated. If you need further information e.g. logs or whatever, I'm happy to provide this. Thanks, Torsten

hensz commented 4 years ago

So while I can live with the workaround, using Shift+select, I still like to use the built-in copy&paste functionality of tmux to copy into the clipboard. Since this is not working with tmux-yank, is someone aware of an alternative way to do this, e.g. with a different plugin?

hensz commented 4 years ago

Is someone reading this? As three user already mentioned, tmux-yank seems to be useless of this is a general issue. Or does anyone see this different?

urey-hiker commented 4 years ago

Is someone reading this? As three user already mentioned, tmux-yank seems to be useless of this is a general issue. Or does anyone see this different?

maybe we should use the origin tmux way to do the samething. https://unix.stackexchange.com/a/131187

hensz commented 4 years ago

There are several suggestions in this thread. I tried a few, but none worked for me. Since I'm not really familiar with Linux clipboard, I don't understand much from these threads and can only copy&paste without understanding what actually is going on here.

Nevertheless, there's this extension, tmux-yank, which should solve exactly this problem, yanking to clipboard, but in fact it doesn't.

urey-hiker commented 4 years ago

There are several suggestions in this thread. I tried a few, but none worked for me. Since I'm not really familiar with Linux clipboard, I don't understand much from these threads and can only copy&paste without understanding what actually is going on here.

Nevertheless, there's this extension, tmux-yank, which should solve exactly this problem, yanking to clipboard, but in fact it doesn't.

My tmux work fine with xsel with this configure in tmux.conf: bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xsel -i -b' My tmux version is 3.1 and this configure should work in tmux version > 2.5 It works the way exactly as tmux-yank, so also check you disable the old run tmux-yank configure. I put my tmux.conf here, you may compare it with yours.

hensz commented 4 years ago

Nope, doesn't work. Since I suspected xsel to behave strange I tested this: echo foo | xsel -ib

This does nothing, the clipboard content (which I then paste with Ctrl+Insert) is still unchanged.

However, when I run xsel with -ip (primary instead of clipboard) pasting with both Ctrl+Insert and middle mouse click pasted "foo\n" -- sadly with a trailing newline, but better than nothing.

So I modified you config entry from xsel -i -b to xsel -ip, just as on the command line. But no luck, pasting doesn't work.

Is there a way to diagnose why this doesn't work? Since currently I don't see where things go wrong. Is it the hook for copy-mode-vi, is it send-keys, is it the copy-pipe-and-cancel event or the xsel command?

hensz commented 4 years ago

I also now tried tmux 3, but the result is nearly identical. The only difference is: With tmux 3 the command xsel -ib works as expected - but only when run from command line, but not together with tmux-yank.

Has anyone ever managed to get copying to the clipboard to work? If yes, how?

hensz commented 4 years ago

Still no update... :-(

mraxilus commented 2 years ago

I take it that this project is abandoned? It would've been really useful...

hensz commented 1 year ago

Since we don't use x-forwarding anymore (for reasons), xsel and xclip doesn't work at all. Thus, this issue is not relevant for me anymore, so from my perspective the issue can be closed.

jobor commented 1 month ago

If wl-copy is installed then it will be picked up automatically. Even if running X11. See the following comment for how to fix this: https://github.com/tmux-plugins/tmux-yank/issues/180#issuecomment-2309004378