tmux-yank icon indicating copy to clipboard operation
tmux-yank copied to clipboard

yank to clipboard using xsel doesn't work

Open hensz opened this issue 5 years ago • 16 comments

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

hensz avatar Jul 22 '19 11:07 hensz

@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.

wizonesolutions avatar Aug 10 '19 12:08 wizonesolutions

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?

hensz avatar Aug 12 '19 08:08 hensz

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.

ebkalderon avatar Aug 17 '19 15:08 ebkalderon

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.

CollinChaffin avatar Aug 31 '19 21:08 CollinChaffin

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 avatar Oct 21 '19 07:10 hensz

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 avatar Dec 13 '19 08:12 hensz

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?

hensz avatar Jan 16 '20 14:01 hensz

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

urey-hiker avatar Apr 27 '20 10:04 urey-hiker

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.

hensz avatar Apr 28 '20 07:04 hensz

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.

urey-hiker avatar Apr 29 '20 01:04 urey-hiker

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 avatar May 05 '20 14:05 hensz

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 avatar Aug 20 '20 07:08 hensz

Still no update... :-(

hensz avatar Oct 23 '20 14:10 hensz

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

mraxilus avatar May 31 '22 17:05 mraxilus

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.

hensz avatar Nov 07 '23 20:11 hensz