This is just awesome!
Install the source-highlight
package (should be available for most distros including Cygwin)
If you have lesspipe installed, make sure you do not have a line like this in your .bashrc, .bash_profile, or .profile:
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
Be aware that by disabling the lesspipe
line above you can no longer read gzipped text files (such as are often found in /usr/share/doc
) with less
but… you can still easily read them with zless
.
Then add these lines (preferably to ~/.bashrc) (this is for Debian):
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=' -R '
Note the path to src-hilite-lesspipe.sh will be different on different systems. Under Cygwin you would use:
export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s"
export LESS=' -R '
This is such a major thing for me, as I often am working on code in a console and referring to other bits of code in other console windows which I have open with less. But it has always been highly annoying when the code in less does not have syntax highlighting.
Reference/credit: blog.tersmitten.nl: How to enable Syntax highlighting in less
Leave a Reply
You must be logged in to post a comment.