1

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.

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

| improve this answer | |
  • I tested in both kitty and gnome-terminal, same behavior. – joelostblom Jan 27 at 9:55
  • How are you copying from tmux? – Nicholas Marriott Jan 27 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". – joelostblom Jan 27 at 10:15
0

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"
| improve this answer | |
  • 1
    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. – Nicholas Marriott Jan 27 at 10:28
  • @NicholasMarriott Thanks! Edited. – joelostblom Jan 27 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.