Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Ubuntu 10.04. My default pager(set using update-alternatives, not $PAGER) is less. The problem is, when I use ri(Ruby documentation tool) with the '-f ansi' mode, less shows the escape sequences(such as 'ESC[36m') instead of displaying the text in color. I can force it to show colors by manually piping the output to less with the -R option, for example:

ri -f ansi String | less -R

However, I'd like this to be the default option when less is used as a pager.

Note: I'm aware that more and most show colors by default, but I use less because of the vi-like key bindings.

share|improve this question
up vote 6 down vote accepted

I found the answer somewhere else. I needed to use lesskey to set up less's options:

$ lesskey -

Then Ctrl+d

did the trick. I'm still not sure why less ignores $LESS though.

share|improve this answer
Aha! the options in ~/.less (which is what lesskey writes) override those in the environment. So you must have had a .less file containing LESS=-r before. – Gilles Aug 11 '10 at 11:56

Set the LESS environment variable to a space-separated list of your favorite options.

share|improve this answer
Didn't work, less totally ignores $LESS. I'm guessing this is an Ubuntu-specific issue, since many other shell variables are ignored, including $PAGER and $EDITOR. – imgx64 Aug 11 '10 at 5:15
less definitely takes $LESS into account, on Ubuntu 10.04 like everywhere else. And $PAGER and $EDITOR work too. It sounds like you're not setting the environment variables properly. How did you do it? – Gilles Aug 11 '10 at 7:15
I tried this: "export LESS='-R'; ri -f ansi String | less" However, less does use other environment variables correctly, such as the ones mentioned here: – imgx64 Aug 11 '10 at 10:01
@imgx64: It Works For Me™, and I don't see how it could not work. Hmmm... What is the output of the two commands type less and env | grep LESS? – Gilles Aug 11 '10 at 10:25
"less is /usr/bin/less" and " LESS=-R LESSOPEN=| /usr/bin/lesspipe %s LESSCLOSE=/usr/bin/lesspipe %s %s " – imgx64 Aug 11 '10 at 11:06

The most likely issue is that you didn't export the less variable.

ls -l | less
<not colorized>

export LESS="FRX"
ls -l | less

You could, for example, create a file called '/etc/profile.d/', with just 'export LESS="FRX"' in it, and your less configuration will be available system-wide.

share|improve this answer
Yer no fun, slim. ..what's wrong with pointing out a bit of necromancy? – Mr. B May 4 '13 at 23:37

Your Answer


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.