Command Line Highlighting – How to Display Syntax Highlighting on a File

catcommand linehighlighting

Is there a variant of cat that outputs syntax-highlighted lines of code when used on a source file?

An idea: maybe vi[m] or another editor can be asked to dump the syntax-highlighted contents of said files to stdout and exit immediately?

Best Answer

Passing the file through pygmentize-f terminal will attempt to detect the type from the filename and highlight it appropriately.

Related Question