Using the scrollwheel in GNU screen

JesperE picture JesperE · Dec 11, 2008 · Viewed 74.3k times · Source

How can I setup GNU screen to allow the mouse's scrollwheel to scroll around in the scrollback buffer? I tried to Google about this, but most hits were on how to allow applications inside screen to use the scrollwheel.

Answer

Pistos picture Pistos · Jul 14, 2009

I believe you can just add a line like this to your ~/.screenrc:

termcapinfo xterm* ti@:te@

Where "xterm*" is a glob match of your current TERM. To confirm it works, ^A^D to detach from your screen, then screen -d -r to reattach, then ls a few times, and try to scroll back. It works for me.


What is this magic? Well, let's consult the manual pages.

screen(1) says:

termcapinfo term terminal-tweaks [window-tweaks]
  [..]
  The first argument specifies which terminal(s) should be affected by this
  definition. You can specify multiple terminal names by separating them with
  `|'s. Use `*' to match all terminals and `vt*' to match all terminals that
  begin with "vt".
  [..]
  Some examples:

      termcap xterm*  LP:hs@

  Informs screen that all terminals that begin with `xterm' have firm
  auto-margins that allow the last position on the screen to be updated (LP),
  but they don't really have a status line (no 'hs' -  append  `@'  to turn
  entries off).  Note that we assume `LP' for all terminal names that start
  with "vt", but only if you don't specify a termcap command for that terminal.

From termcap(5):

String capabilities
    [..]
    te   End program that uses cursor motion
    ti   Begin program that uses cursor motion