Using screen, commands like less and man don't clear the screen afterwards

15

10

In contrast to this question I want the clearing of the screen re-enabled for less. It works fine in my xterm terminal under Cygwin/mintty or Gnome Terminal (both xterms).

However, when inside a screen session, the clearing of the screen is somehow disabled. I tried several things, like

screen -T xterm

or putting the autonuke statement in my ~/.screenrc. Also, inside the screen session

export TERM=xterm
tset

has no effect. So, now I'm out of ideas. Any help appreciated.

Boldewyn

Posted 2010-05-05T07:00:48.147

Reputation: 3 835

hmm, i'm seeing the same thing, on Cygwin/mintty, Debian/putty, Ubuntu/putty. in putty i use putty as the TERM instead of xterm but that's the only real difference. – quack quixote – 2010-05-05T08:21:11.407

Answers

21

You probably want to avoid screen -T or resetting TERM away from its default value while inside screen sessions (it should probably be screen or at least something that starts with screen).

Try putting the following line in your .screenrc:

altscreen on

To activate it on a per-session basis, you can do Control+a:altscreen onReturn.

My manpage says:

altscreen on|off

If set to on, "alternate screen" support is enabled in virtual termi- nals, just like in xterm. Initial setting is `off'.

BTW, I have explained the root cause of the “screen clearing” (actually alternate/normal screen swapping) in another answer. It is possible that your screen terminfo entry is missing smcup/rmcup or that your screen does not support alternate screens. Both of those seem less likely that altscreen being off.

Chris Johnsen

Posted 2010-05-05T07:00:48.147

Reputation: 31 786

i read your alt-screen explanation a few days ago and figured it was related. thanks for the excellent writeups -- i'm putting this in my .screenrc right now. – quack quixote – 2010-05-05T10:08:26.833

I'm using Mac and I don't have an altscreen command. Any other way of doing this? – Dana – 2011-06-30T17:22:06.690

2

@Dana: What version of screen (screen --version)? It seems that altscreen has been around since screen 3.9.13. Based on opensource.apple.com, it seems like the Apple-bundled version of screen has been newer than 3.9.13 since 10.3. Just as a reminder, it is not a regular “shell command”, but a command that is specific to screen; it must be entered at the screen “colon prompt” (Control+a, then :altscreen on, then Return).

– Chris Johnsen – 2011-06-30T22:54:27.793