GNU screen: change focus in split windows with mouse

16

5

Is there a way to enable proper mouse support in GNU screen so that I can switch the focus between split windows using my mouse?

In other words, I'm looking for a mouse-driven alternative to typing 'C-a Tab'.

Thanks,

enricoferrero

Posted 2013-08-07T09:34:45.027

Reputation: 589

Answers

26

One can add

mousetrack on

to ~/.screenrc

Patrick Sanan

Posted 2013-08-07T09:34:45.027

Reputation: 374

1On the mac you'll need to install the latest screen (e.g. from homebrew) to use this feature. The version of screen that ships currently doesn't recognize the mousetrack command. – Pat Niemeyer – 2017-02-24T16:09:14.127

Game changer. Thanks! – Mark – 2019-03-10T02:39:38.027

2

I realize this question is a little old, but I'd like to add that mousetrack seems to swallow the mouse events used for drag-select, at least on my installation of Ubuntu 16.04. So you have a choice: click-to-focus, or drag-select to highlight/copy text.

The workaround I've found for this is to bind a pair of keys to toggle mouseselect on & off. In ~/.screenrc:

# Click region to focus, toggled by Alt-[ / Alt-]
# (When on, swallows mouse events for drag-select)
bindkey "^[[" mousetrack off
bindkey "^[]" mousetrack on

Nathan Winant

Posted 2013-08-07T09:34:45.027

Reputation: 21

With mousetrack switched on you can select the start (first click) and end (second click) of a selection in copy mode. – Gergely Máté – 2020-01-09T17:45:30.513

2

I believe that GNU Screen's upstream may have proper mouse support. See Mouse in screen(1) on the Linux console?.

Also check Debian Sid (unstable), since according to the first answer found for the said post, Debian Unstable has the latest version/release thingy of GNU Screen.

This, however, may mean that you'll have to build Screen from source, which in of itself shouldn't be too difficult, but if you've never done this kind of thing before it can be a bit intimidating.

Alexej Magura

Posted 2013-08-07T09:34:45.027

Reputation: 134

I am using Debian Jessie, seems that mousetrack on not works for me. Is that the version issue? I check the dpkg -s screen, the version is Version: 4.2.1-3. While screen -v print Screen version 4.02.01 (GNU) 28-Apr-14. Kind of weird. – Tmx – 2015-04-03T07:38:42.840

@Tmx I'm not sure; I don't use Screen or Tmux anymore, sorry. It's unlikely to related to the fact you're using Debian Jessie: it's much more likely that you're using the wrong version. If your package manager says one thing, but the package says another: believe the package. I'd try building the latest stable version of Screen from scratch and see if it starts working. – Alexej Magura – 2015-04-03T07:57:12.737

1Yes! I can confirm this works on Debian testing too. Just insert mousetrack on in ~.screenrc. – enricoferrero – 2013-11-13T19:07:58.373

I can also confirm that this sucker definitely works on Mac OS X, it's a bit tricky to compile, feel free to use the homebrew formula I wrote. I'm also planning on writing a build script for unix-like systems in general, but that'll have to wait for a bit. NOTE on Mac OS X, at least for me, I had to specify mousetrack on instead of whatever the other options where, in order to get it work.

– Alexej Magura – 2013-11-13T21:34:20.750

0

GNU screen does not use the mouse in any way.
If you want that behaviour, you could try tmux instead. To enable that behaviour in tmux, add the following line to ~/.tmux.conf :

set -g mouse-select-pane on

RPDiep

Posted 2013-08-07T09:34:45.027

Reputation: 33

I see, that seems to explain why I can't find this information anywhere. – enricoferrero – 2013-08-08T20:44:29.987

2This is outdated; the latest version of screen does support use of the mouse. – Patrick Sanan – 2014-06-12T06:31:16.433