Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by Sathya Sep 27 '12 at 12:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers

up vote 5 down vote accepted

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

altscreen

You can also do Ctrl-a : altscreen 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.

share|improve this answer
add comment

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
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.