Is there a method to colorize the output of cat, the way grep does.
For grep, in most consoles it displays a colored output hi
I have written the small script to perform the colourization using pygmentize.
colorize_via_pygmentize() {
if [ ! -x "$(which pygmentize)" ]; then
echo "package \'Pygments\' is not installed!"
return -1
fi
if [ $# -eq 0 ]; then
pygmentize -g $@
fi
for FNAME in $@
do
filename=$(basename "$FNAME")
lexer=`pygmentize -N \"$filename\"`
if [ "Z$lexer" != "Ztext" ]; then
pygmentize -l $lexer "$FNAME"
else
pygmentize -g "$FNAME"
fi
done
}
And then make an alias to script. alias cat=colorize_via_pygmentize. Also dont forget to save this in ~/.bashrc.