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.

The default behavior for 'less' is to clear the screen after quitting. This behavior stopped when I started using:

export TERM=xterm

Now 'less' leaves the last page I viewed on the screen, and I want to re-enable the default behavior of clearing the screen.

Googling this problem I found that people use the following command in their ~/.screenrc:

altscreen on

I'm not sure if this is a mac-issue but I don't have this command available.

I'm using bash shell on Mac terminal and I have no $LESS environment variable defined.

share|improve this question

migrated from stackoverflow.com Jun 30 '11 at 15:13

This question came from our site for professional and enthusiast programmers.

1  
This isn't a duplicate. The other question explicitly asks about the problem inside GNU screen. This one has nothing to do with screen, as evidenced by, "I don't have [altscreen] available" and "I'm using bash shell on Mac terminal." –  user112553 Jun 30 '11 at 19:02
    
What happens when you call less like: less -+F -+X <file>? If that changes the behavior, your less is configured to behave that way somewhere in you system configuration. If not, it's likely that your terminal doesn't support the alternate screen feature or doesn't have it enabled. You'd need the reverse of superuser.com/questions/136162/… or get a terminal that has the alternate screen feature. –  user112553 Jun 30 '11 at 19:11
    
@peth: This really isn't a duplicate question. As for your question, no matter how I play with the command line options, the last page always remains on the screen. I don't think this has something to do with the less configuration since this only started happening after I defined export TERM=xterm. Thanks for your help! –  Dana Jul 1 '11 at 16:02

1 Answer 1

Take a look at your $LESS environment variable and make sure it doesn't specify -X. I specifically add this to $LESS, because I don't want the screen cleared. Here is a snipet from the manpage:

-X or --no-init Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deini- tialization string does something unnecessary, like clearing the screen.

share|improve this answer
    
I have no $LESS environment variable defined at all –  Dana Jun 30 '11 at 17:20
    
As mentioned in the question, this only started happening after I defined export TERM=xterm, so I believe this is not a problem of less definitions. –  Dana Jul 3 '11 at 22:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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