3

When I copy from tmux, selections are appended to the system clipboard rather than replacing its existing content. I see this behavior both with mouse drag and release, and using the keyboard to copy selections. I would like to change the behavior so that copying from tmux works the same as copying elsewhere, i.e. it replaces the content in the system clipboard with the content copied from tmux.

This is with tmux3.0a on 5.4.13-arch1-1 GNU/Linux. I tested with a clean .tmux.conf only containing set -g mouse on in both kitty and gnome-terminal.

3 Answers 3

1

What terminal? IIRC there is one terminal that appends by default but I forget which one (maybe Kitty? it sounds like the sort of stupid thing it would do).

3
  • I tested in both kitty and gnome-terminal, same behavior. Jan 27, 2020 at 9:55
  • How are you copying from tmux? Jan 27, 2020 at 10:09
  • I tested both drag'n drop and space + enter, same behavior. However, your comment made me test in additional terminals and I noticed that in xterm and konsole, tmux did not copy text to the clipboard at all. That plus your comment made me consider that maybe tmux was not putting the text in the system clipboard, but the terminal was (not sure if this even makes sense). I added the following line to my config and the mouse copy behavior now works as expected in all tested terminals bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xsel -b". Jan 27, 2020 at 10:15
1

The comments from Nicholas made me consider that maybe tmux was not putting the text in the system clipboard, but the terminal was. I added the following lines to my config to ensure that tmux was putting the lines in the system clipboard and the mouse and keyboard copy behavior now works as expected in all tested terminals.

set -g set-clipboard off
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xsel -b"
bind-key -n -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xsel -b"
3
  • 2
    You will need to turn set-clipboard off as well if you are going to do this or there will be a race between the terminal setting the clipboard and xsel doing it. Jan 27, 2020 at 10:28
  • @NicholasMarriott Thanks! Edited. Jan 27, 2020 at 10:29
  • Awesome, this fixes the same issue! :-)
    – mmngreco
    Apr 23, 2021 at 8:32
1

Late to the party, but might help someone.

Since in the comments you've said you've tested Kitty terminal, I can only assume you also use it. I can reproduce this there, but not in gnome terminal.

For kitty, I'd recommend adding no-append to clipboard_control ( see github issue ). For some reason it's lacking from the docs, but it's in the changelog (CTRL+F for "no-append" ). And I can confirm it works for me.

Press CTRL+SHIFT+F2 to open the config. If one doesn't already exist, it will create a default config at ~/.config/kitty/kitty.conf when you do this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .