on quit, 'less' does NOT clear its contents when run in a 'screen' session [duplicate]

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

When I quit 'less' in a normal bash, it clears the previous contents displayed by 'less' and shows the bash contents again. This is the defualt behavior and what I desire.

However, when I use 'less' in a 'screen' session (still bash inside the screen session), after quitting it does not erase the contents shown by 'less' and the contents of bash are gone (still having a new bash comand line prompt though).

How can I make it so that less does clear its display after quitting, even though I am using it within a 'screen' session?


Try adding this command to your ~/.screenrc file:

altscreen on

You can also do Ctrl-a : altscreen on from within screen to toggle it on or off in the current session.

Make sure your $LESS environment variable does not contain X in its value.


Also check that these work:

$ tput smcup | od -c
$ tput rmcup | od -c

they should print something like:

0000000 033  [  ?  1  0  4  9  h

rather than:

0000000