07.24
I wanted to have syntax highlighting for a big SQL file I was working on. Finding a solution didn’t take my too long. Source-highlight given a source file, produces a document with syntax highlighting. Output formats that are supported:
- HTML
- XHTML
- LATEX
- TEXINFO
- ANSI
- DocBook
Input formats that are supported:
- Ada
- Asm
- Applescript
- Awk
- Autoconf files
- Bat
- Bib
- Bison
- C/C++
- C#
- CakePhp templates
- Clipper
- Cobol
- Configuration files (generic)
- Caml
- Changelog
- Css
- D
- Diff
- Erlang
- errors (compiler output)
- Flex
- Fortran
- GLSL
- Haskell
- Haskell literate programming
- Haxe
- Html
- ini files
- Java
- Javascript
- KDE desktop files
- Latex
- Ldap files
- Lisp
- Logtalk
- Log files
- lsm files (Linux Software Map)
- Lua
- Makefile
- Manifest
- M4
- ML
- Oz
- Pascal
- Perl
- pkg-config files
- PHP
- Postscript
- Prolog
- Properties files
- Protobuf (Google’s Protocol Buffers)
- Python
- RPM Spec files
- Ruby
- Scala
- Shell
- S-Lang
- Sql
- Tcl
- Texinfo
- Vala
- VBscript
- XML
- XOrg conf files
Exactly what I needed!
For Debian/Ubuntu get source-highlight to work is just as simple as:
apt-get install source-highlight
And adding these two environment variables (to .bashrc):
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" export LESS=' -R '
The result looks like this:
Be sure this line isn’t present in your .bashrc because it will interfere with source-highlight:
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
For CentOS/Red Hat the procedure will be comparable, but I don’t now for sure if a RPM package of source-highlight is available.
References:

No Comment.
Add Your Comment