45

When I use screen inside a putty session, I can't seem to use the scrollback buffer of putty to look at whatever just scrolled off the screen. Instead, I just see what was happening in the putty session just prior to my running screen.

What am I missing here? I like being able to scroll back, and I don't want to use the screen functionality to look at the past buffer; the scroll wheel on my mouse doesn't have hooks into screen and I don't expect it ever would.

Thanks!

chris
  • 11,784
  • 6
  • 41
  • 51

4 Answers4

45

You might also check out the Screen FAQ which allows a sort of hybrid behavior:

Summary: add the line to your .screenrc file:

termcapinfo xterm ti@:te@

Reference ( Putty FAQ )

PuTTY's terminal emulator has always had the policy that when the ‘alternate screen’ is in use, nothing is added to the scrollback. This is because the usual sorts of programs which use the alternate screen are things like text editors, which tend to scroll back and forth in the same document a lot; so (a) they would fill up the scrollback with a large amount of unhelpfully disordered text, and (b) they contain their own method for the user to scroll back to the bit they were interested in. We have generally found this policy to do the Right Thing in almost all situations.

Unfortunately, screen is one exception: it uses the alternate screen, but it's still usually helpful to have PuTTY's scrollback continue working. The simplest solution is to go to the Features control panel and tick ‘Disable switching to alternate terminal screen’. (See section 4.6.4 for more details.) Alternatively, you can tell screen itself not to use the alternate screen: the screen FAQ suggests adding the line ‘termcapinfo xterm ti@:te@’ to your .screenrc file.

KnipSter
  • 599
  • 4
  • 4
17

To scroll back, press ^A (Ctrl-A, or whatever your screen control sequence is if you remapped it) and then Esc. This will let you move the cursor up and down. PgUp/PgDn will let you scroll up and down inside of screen.

The reason for this is the way that screen handles the scrollback buffer. Screen always draws the full text area, and has its own backbuffer that you must control with screen. This is similar to using programs, like vi or joe, that take up the entire text area and provide their own buffer: scrolling up in your terminal emulator just gives garbage, but scrolling up inside those programs gives your intended result.

Andrew Scagnelli
  • 391
  • 1
  • 2
  • 9
  • So the only way I'd be able to use the scroll wheel on my mouse (okay, I *am* that lazy!) is if I remap it to somehow send [screen escape key] then ESC then up and down? Ugh, that's too much work... – chris Jun 26 '09 at 17:18
  • @chris: If you're using putty, you should already have your hands on the keyboard. If you have a laptop, try seeing if you can remap some keys you don't use as frequently to PgUp/PgDn. – Andrew Scagnelli Jun 26 '09 at 17:54
  • 1
    many times you're looking at a long command output in putty, and it's more convenient to scroll back and forth with the wheel than with the keyboard. – Elazar Leibovich May 08 '11 at 09:07
2

That's because of how screen works. Screen does a dynamic update of your whole text area, rather than pushing new lines at the bottom of the screen which in turn pushes the top line into the scroll-back area. It redraws the whole screen when a new line shows up, which prevents more data going into scroll-back. The same problem exists in 'less' when not using screen.

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
  • I can't say I'd ever noticed with less, but that's probably because I'm always inside screen to begin with. Thanks for the specifics of the hows and whys! – chris Jun 26 '09 at 17:20
1

Screen with Putty scrollback is working automatically in Solaris 10. It seems to be doing what KnipSter said by default even though I do not have a .screenrc file. The problem with this approach is that, if you detach and re-attach then there is no scrollback buffer in Putty and you must resort to using Screen's scrollback as described by Scagnelli.

  • Screen comes with solaris 10 these days? Is it a sun massaged version or is it whatever you get from gnu? This is really interesting that it works this way in this specific case. Thanks for the info! – chris Aug 26 '09 at 19:04