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
There is a colorized version of cat - ccat. Get it from https://github.com/jingweno/ccat/.
It is a single standalone executable so to install it you can unpack the binary version for your OS from https://github.com/jingweno/ccat/releases and copy the ccat binary for example to /usr/local/bin.
If you want to avoid binaries, or if there is no binary for your platform (e.g. raspberry pi, etc), then you can alternately compile from source given that you have a working go development environment (apt install golang on debian-based linuxes or brew install golang on mac):
go get -u github.com/jingweno/ccat
The
ccatbinary will be created under your$GOPATH/bin.
brew install ccat
catTo replace regular cat with ccat add in ~/.bashrc (~/.zshrc, etc..):
alias cat="ccat $*"
alias cat0="/bin/cat $*" # for cases when you need plain `cat`
ccat is implemented in Go, so it is a native binary which runs much faster than Python-based solutions, such as pygments, the module behind pygmentize; I didn't see any noticeable speed difference between cat and ccat.