4

I'm using macOS and tmux 3.1c. When copying a text via mouse selection, the highlight will be auto-cleared after copying the text to clipboard, this will make it difficult to keep track the last line you copied when you go back to it:

enter image description here

Is there a way to prevent/disable the auto-clearing of selection after copying? I know about pressing Shift, then selecting the text, and then hitting Cmd + C to copy it to the clipboard, which preserves the selection. But this is relatively inefficient workflow. This is the same behavior with Alacritty/iTerm.

In iTerm, without tmux, selecting a text will auto-copy it in the clipboard, but the selection will not be auto-cleared.

Ranel Padon
  • 143
  • 5

1 Answers1

5

You are looking for the copy-selection-no-clear command.

For example, if you are using vi mode, you can define y to copy the selection without clearing it:

bind-key -Tcopy-mode-vi y send -X copy-selection-no-clear 

For emacs use the copy-mode table.

laktak
  • 5,616
  • 20
  • 38
  • Exactly what I want! Ended up with `bind-key -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-no-clear` since I usually use the mouse for selection, and it works as intended. Thanks! – Ranel Padon Mar 15 '21 at 15:42
  • @RanelPadon glad this helped. don't forget to accept the answer so your question no longer shows up in the unanswered section. – laktak Mar 16 '21 at 08:12
  • Sorry, what do you mean of "accept the answer"? I already upvoted your answer. Am I missing something? Thanks – Ranel Padon Mar 16 '21 at 10:10
  • 1
    Interesting, didn't know that I could accept an answer also, I should have done this even before in my StackOverflow posts. Although some of them, I ended up the one who solved it also. Cheers https://stackoverflow.com/help/someone-answers – Ranel Padon Mar 16 '21 at 10:16