Clear GNU Screen After Full-Screen Application – Terminal Tips

command linegnu-screenterminal

When working at a normal xterm (not sure about a "real" terminal), when a full-screen program such as man or vim is closed, it disappears, leaving your screen so you can see your prompt, and previous prompts including where you launched the program that closed.

When I am running within GNU Screen, however, when the program is closed it does not clear but is simply shifted up so a prompt can be displayed. To me this is ugly, and I'd like to know if "normal" behaviour can be resumed.

I realise I could manually clear the screen myself but a) I don't want to and b) that would result in a totally clear screen, not what I'm after (though perhaps better, if this is as good as it gets).

Best Answer

Some terminals, such as xterm, support what is known as an “alternate screen”: there are separate screens for full-screen programs and for scrolling programs. In xterm, you can switch between the two screens with the “show alternate screen” command at the bottom of the Ctrl+mouse 2 menu.

This behavior is disabled by default in screen but can be enabled with the altscreen option: add altscreen on to your ~/.screenrc.

Related Question