Sunday, September 25, 2011

Syntax highlighting for less

Sometimes I happen to come across things that I didn’t know I need until I see them. One of these things is the ability to have syntax highlighting within less. The package that makes this possible is src-highlite. Under Archlinux it is packaged as source-highlight.

After installing that package you’ll need to activate it by setting up the following two environment variables:

export LESSOPEN="| /usr/bin/ %s"
export LESS=" -R "

The path to might be different on your system. So adjust it if necessary.