72

Is there any way to use the mouse wheel to scroll through the output of a screen session?

I can use the keypad scroll through previous output in screen after pressing ctrl+a [. Is it possible to do this with the mouse wheel?

(I'm using putty, but I don't think it's a putty issue, I believe it's a screen issue.)

4
  • 3
    You need to tell PuTTY to send the mouse wheel events into the terminal instead of keeping them for itself. (I don't know if it's possible, but check the manual, it's pretty good.) Aug 3, 2011 at 20:41
  • Even on a regular terminal session in screen, I haven't been able to get scrolling working properly outside of screen's "copy mode." I think it's a limitation of the program and not so much a Windows/Putty issue, but I could be wrong. Aug 3, 2011 at 22:59
  • Our of curiosity, have you guys tried the same thing in tmux?
    – Caleb
    Aug 4, 2011 at 7:04
  • @Caleb: mouse wheel on tmux works like a charm (although I'm not trying it from a putty, I don't have windows:))
    – Torian
    Aug 18, 2011 at 4:02

5 Answers 5

81

Mouse scrolling and elevators will work if you enable them in your .screenrc.

Screen FAQ

Q: My xterm scrollbar does not work with screen.

A: The problem is that xterm will not allow scrolling if the alternate text buffer is selected. The standard definitions of the termcap initialize capabilities ti and te switch to and from the alternate text buffer. (The scrollbar also does not work when you start e.g. 'vi'). You can tell screen not to use these initialisations by adding the line termcapinfo xterm ti@:te@ to your ~/.screenrc file.

So in my .screenrc, I have:

termcapinfo xterm* ti@:te@

In tmux, it'd be something like (.tmux.conf):

set -g terminal-overrides 'xterm*:smcup@:rmcup@'
0
15

Although it is an old question, the method I found best that works for me is using Ctrl + A + ESC key combination. This makes the screen output scrollable. From the documentation page:

Virtual terminals in Screen can be manipulated by pressing the Ctrl+A key combination, and subsequently pressing a key to execute one of the commands given below:

Esc lets you scroll back and forth in your terminal output

You can find the documentation here

2
  • 1
    This is a nice answer that point to a builtin screen feature that fix the issue of this question without any configuration change. Aug 15, 2018 at 16:52
  • 3
    It's worth mentioning that copy mode (C-a, ESC) pauses any currently-running process in the window in which it was used: superuser.com/questions/220139/… Jan 28, 2019 at 18:43
3

That's not the final solution, if you use this

termcapinfo xterm* ti@:te@

then the mouse scroll support will be broken inside vim i.e. mouse=vi

2
  • Would it be possible to edit .screenrc so that when you enter vim this is turned off and turned back on when exiting?
    – fbence
    Jan 16, 2017 at 10:11
  • well, this is acceptable since I nearly do not use mouse scroll in vim anyway
    – andrej
    May 28, 2018 at 14:04
1

What Gilles suggested is probably the best answer, if it is possible to do.

If it is not, a workaround that should work would be to use x-mouse control to send up and down arrow keys whenever the mouse is scrolled. I've never used screens with putty, but I have used this setup on putty in windows to be able to scroll through a text file with vi or nano. I had different profiles setup, one for 3 line scroll and one for 1 line scroll.

2
  • When I'm using vim, I have set mouse=a to enable mouse scrolling. This works in putty without using screen, but it doesn't work when using screen. How do you set up x-mouse control?
    – kristi
    Aug 5, 2011 at 18:08
  • just visit the website and download the software, it's pretty self explanatory. It's a GUI app. Aug 11, 2011 at 22:14
1

Mouse scroll wheel works well with for example elinks running inside screen, which in turns runs inside gnome-terminal, so it is indeed possible. In putty tray it doesn't, tho.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .