Ubuntu – Change less (pager) default options

lesspagerUbuntu

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.

Best Answer

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

$ lesskey -
#env
LESS = -R

Then Ctrl+d

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

Related Question