42

I'm using tmux 2.1 and tried to on mouse mode with

set -g mouse on

And it works fine, I can switch across tmux window splits by clicking the appropriate window. But the downside of this is that I cannot select text with mouse. Here is how it looks like:

enter image description here

As you can see, the selection just become red when I keep pressing the mouse button and disappear when I release the button. Without mouse mode enabled the "selection with mouse" works completely fine.

Is there some workaround to turn mouse mode on and have the ability to select text?

62

If you press Shift while doing things with the mouse, that overrides the mouse protocol and lets you select/paste. It's documented in the xterm manual for instance, and most terminal emulators copy that behavior.

Notes for OS X: In iTerm, use Option instead of Shift.  In Terminal.app, use Fn.

  • 9
    Note: On iTerm for MacOS use option instead of shift – KNejad Feb 16 '18 at 13:00
  • 1
    @KNejad This doesn't work on macOS High Sierra inside the Terminal.app. Any ideas? – Bastian Gruber Feb 21 '18 at 10:00
  • 9
    @BastianGruber From the comments section of this SO answer I found that on Terminal.app you should use the FN key – KNejad Feb 21 '18 at 13:51
  • 6
    This approach doesn't work well if you have multiple tmux panes. I can select the text, but the selection overlaps terminal lines across all the tmux panes. – Eddy R. May 17 '18 at 23:09
  • 1
    @EddyR. This is where ctrl-b + z comes in handy. – cfz42 Oct 27 '18 at 21:14
1

Thomas Dickey's answer is probably what most people are looking for.

To give some more context on the behavior you are observing, when tmux's mouse mode is on it enables text selection within a particular pane. That's the red text highlighting shown in your screenshot. It can be useful when you have split panes and want to only copy text within one.

When you release the mouse button the selected text is copied to tmux's internal clipboard. You can then paste that text using Ctrl+B ].

Unfortunately it does not copy to the system's primary clipboard, so you can't select in tmux and then paste into a browser for instance. You can configure that behavior though. See this answer to How to copy and paste with a mouse with tmux.

  • "clipboard" and "primary" are two types of selection – Thomas Dickey Jun 14 at 23:11

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.