Install source-highlight:
sudo apt-get install source-highlight
Add the following two lines to
~/.bashrc
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=' -R '
Now source files opened with
less will be nicely syntax highlighted.
source-highlight supports many languages - see
source-highlight --lang-list
for a full listing.