I already know that I can colorize output with grep and with a couple of different ways. I want to have something like supercat, but for commands (and not that dead).

The application Supercat colors any input text based on the type of file and a set of rules associated with the file type. The rules are used to match strings found in the input text and can be specified using simple characters or strings, regular expressions and special time-formatting rules.

Lets say, I'm writing magiccommand gcc blah blah, this magic command understands that it has to colorify gcc output and chooses one template. Now, I'm willing to magiccommand mvn foo bar and that command takes another appropriate rule. Bonus points for readable rules -- no "s/^GET.*$/\x1b[31m&\x1b[0m/" sed insanity.

up vote 11 down vote accepted

You could use a tool like grcat/grc (where the first is the tool, and the second the front end).

grc will execute command command with optional parameters [args] piping its stdout or stderr into grcat, with apropriate configuration file.

For example

enter image description here


You may also find interesting source-highlight released under GNU.
You can add it as alias e.g. in your .bash_aliases with something like the line below.

alias Cat='source-highlight --out-format=esc -o STDOUT -i'  
Cat myfile.c # or myfile.xml ...

Or you can do a similar alias (without the -iat the end to have the possibility to pipe in)

alias PCat='source-highlight --out-format=esc -o STDOUT '
tail myfile.sh | PCat     # Note the absence of the `-i`

Screen Example

Excerpt from apt-cache show source-highlight:

Description-en: convert source code to syntax highlighted document.
This program, given a source file, produces a document with syntax highlighting.
It supports syntax highlighting for over 100 file formats, including major programming languages, markup formats, and configuration file formats. For output, the following formats are supported: HTML, XHTML, LaTeX, Texinfo, ANSI color escape sequences, and DocBook

Among the options that you can read from man source-highlight the -s

-s, --src-lang=STRING source language (use --lang-list to get the complete list). If not specified, the source language will be guessed from the file extension.

--lang-list list all the supported language and associated language definition file

The problem with grc is you can't pipe into it, but you can pipe to its underlying grcat program. So first:

Install grcat

sudo apt-get install grc

Now execute:

echo "[SEVERE] Service is down" | grcat ~/conf.username

Where conf.myusername contains:


Try ccat

$ ccat file.yml $ ccat file.py $ ccat file.rb $ ccat file.go ...

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.