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

linux, xsel: Primary paste in the tmux window doesn't work immediately

Open tompreston opened this issue 5 years ago • 3 comments

With set -g mouse on, when I highlight text tmux-yank copies it to the primary buffer using xsel. When I immediately try to paste this text in any pane (using shift+middle-click) in the same tmux instance it fails to paste. xsel -p prints the previously highlighted text - so the copy part is working, just paste isn't.

If I middle-click into any other window, the paste works. And from then on, the paste also works in tmux. This suggests to me that there is something blocking the shift-middle-click paste in tmux, until the terminal window loses focus. Copy/primary-paste continues to work for a short time after this, then it happens again (after ~2 mins).

This happens in fullscreen or windowed mode and seems to also apply to the clipboard buffer (when text is copied by pressing "y" instead of mouse-up).

I'm aware I can just bypass tmux by holding down Alt, but this doesn't work with panes as it selects a whole line across the display. I'd like to copy multi-line per pane.

I'm not sure how to debug the middle-click paste event in tmux. What debug options can I turn on to print more information about this? Thanks

tmux 2.9a, Fedora 32, gnome-terminal 3.34.2

tompreston avatar Jan 23 '20 14:01 tompreston

I can reproduce this faster with the following sequence:

  1. Shift-highlight, to bypass (un-focus?) tmux and copy text to primary buffer
  2. Shift-middle-click, to paste primary buffer into tmux
  3. Normal "mouse on" highlight, to tmux-yank copy text to primary buffer (works)
  4. Shift-middle-click, to paste primary buffer into tmux (does not work)

I can paste the primary buffer selected in 3 into another terminal. After this the paste works again in the first tmux/gnome-terminal instance.

tompreston avatar Jan 24 '20 16:01 tompreston

Another quick workaround is to highlight text and mouse-up (copying to primary clipboard), then press the super-key (Windows key) twice. In Gnome 3, this enters and leaves the "Activities" overview (I think that's what it's called) - re-focusing the terminal and letting me paste with middle-click.

I think the next steps to debug this are:

  • Reproducing on another machine/os (maybe it's just me?)
  • Reproduce with upstream tmux
  • Add debug to upstream tmux mouse-up and middle-click events
  • Add debug to "paste" action - if that's even a thing.

Hopefully someone with more knowledge of tmux can point me in the right direction.

tompreston avatar Jan 27 '20 15:01 tompreston

I use mobaxterm on win10 locally ,ssh to remote ubuntu 20.04, run in tmux. Yank is quite slow too.
Look forward to improvement.
Thx!

sisrfeng avatar Dec 08 '21 02:12 sisrfeng