A man/less Trick

I regularly use man pages. I also regularly use less to view files I wanna read.

$ man vsftpd.conf

$ man named.conf

$ man less

$ less README

$ less CHANGES

and so on and so forth. But one of the most annoying things about the default setting to less. The one that I wonder what the devs were thinking when they created this application, is the way that it works by default. When I exit from one of my man pages, or when I finish reading a document using less, I discover that the page has disappeared. Gone!

No text! Zip, nada, buh-bye!

Annoying!!

So today in class, one of my students asked me if there was a way to fix this problem. I said that I thought there was, but couldn’t remember the option. I found that switch and thought that others might like to know as well.

The option is -X. If you run man less you will find it in the OPTIONS section. The only trick is, I didn’t want to create an alias for it, but rather wanted it to be the default. Luckily for me, there is an environment variable called LESS that I can set, so that’s what I did.

I added the following to the bottom of my ~/.bashrc file:

export LESS=”-isXf”

and I modified my /etc/man.config file to match:

PAGER /usr/bin/less -isXf

Now, when I hit the q button either in a man page or when I less a text document, the content stays on the screen. Very nice!

Cheers,

Herlo

Posted on April 13, 2007 at 8:00 am by herlo · Permalink
In: Tech, Tools

One Response

Subscribe to comments via RSS

  1. Written by Lonnie Olson
    on April 17, 2007 at 7:38 am
    Permalink

    Yay! Thanks. Ever since I switched to Linux at work from FreeBSD this has annoyed the hell out of me.

    It never happened on FreeBSD. Probably because of the termcap differences.

Subscribe to comments via RSS

Leave a Reply