📅 2013-Dec-30 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cat, pygments, syntax highlighting ⬩ 📚 Archive
Some people like to quickly have a look at short source files using cat
at the terminal. It would be nice to have syntax highlighting for such a use. Though cat
does not support syntax highlighting, it is easy to get a similar experience using Pygments, a syntax highlighter written in Python.
First, install Pygments using pip
:
[code lang=bash] $ sudo pip install Pygments
This installs a `pygmentize` program, whose `-g` can be used to request it to guess the type of input file and apply the appropriate syntax highlighting:
[code lang=bash]
$ pygmentize -g foobar.cpp
If you use this regularly, create an alias for it with a name that is easy to remember like ccat
.
Tried with: Pygments 1.6, Python 2.7.3 and Ubuntu 12.04