Syntax highlighting for less

  Sunday, September 25, 2011

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/src-hilite-lesspipe.sh %s"
export LESS=" -R "

The path to src-hilite-lesspipe.sh might be different on your system. So adjust it if necessary.