Is there a method to colorize the output of cat
, the way grep
does.
For grep
, in most consoles it displays a colored output highlighting the searched keywords. Otherwise, you can force it by calling grep --color
Is there a generic way to color the output of any program according to your personal choice.
From what I understand, the program itself is not responsible for the colors. It is the shell.
I am using the default shell in FreeBSD 5.2.1 which looks like it has never seen colors since epoch.
If you just want a one liner to set
cat
output to a given color, you can appendalias cat="echo -en 'code' | cat - "
to your
~/.$(basename $SHELL)rc
Here is a gist with color codes: https://gist.github.com/chrisopedia/8754917
I like
'\e[1;93m'
, which is high intensity yellow. It looks like this:vimcat
is single-file (shell script) and works good:http://www.vim.org/scripts/script.php?script_id=4325
Last update is from December 2013. Hint: you can force file type recognition by
vimcat -c "set ft=<type>"
.In this question https://superuser.com/questions/602294/is-there-colorizer-utility-that-can-take-command-output-and-colorize-it-accordin
grcat
/grc
tool was recommended as alternative tosupercat
.Man of grc and of
grcat
; it is part of grc package (sources):Options:
pygmentize is good. I have an alias:
but highlight is another widely available alternative is
Installation:
You may have to install
pygments
using:and for
highlight
package which is easily available on all distributionsIn Action:
I'm attaching shots for both down below for a good comparison in highlightings
Here is
pygmentize
in action:and this is
highlight
: