Scroll wheel functionality in GNU Screen

GNU Screen is one of my biggest time savers in work. It allows me to handle multiple shell and SSH sessions in one virtual terminal, and ensures those sessions stay alive even when I lose network connection due to switching access points, plugging in to a wired network or just general network issues, uh-ohs and whoopsies.

Screen works pretty well “out of the box”, as long as you learn a handful of essential commands/key bindings, like Ctrl+A+D (detach from session), screen -r session-name (re-attach to existing session) and Ctrl+A+numkey, where numkey represents a particular session.

By default, however, Screen does not work with your mouse scroll wheel (or touchpad two-finger scroll, etc.). Here is a little snippet you can add to your Screen config to enable this. The Screen config file is located in your home directory, at ~/.screenrc

termcapinfo xterm* ti@:te

After writing this to your .screenrc file, just launch a new session using screen -S session_name (or just screen if you’re not a fan of session names) and, voilĂ , you should now have scroll wheel functionality.

Note: There are some gotchas to this, mainly that the scrollback buffer seems to get shared across windows in a session, so you’ll often get the scroll buffer of another window “mixed in” with your current window.

Thanks to Pistos on Stack Overflow for this solution.