Colorizing Output from the cat Command
22 Jun 2014I have a special function called pcat, which stands for “pretty catenate”, saved in my dotfiles repository on github. I really wish this style of cat would be the default on modern machines.
Here it is, sans link:
function pcat() {
pygmentize -f terminal256 -O style=native -g $1 | less;
}
alias cat=pcat
I’ve omitted the part where you get pip
installed on your machine first, and install the pygments
module for colorizing output based on a detected language. This is required.
Here’s an example of what the output looks like on my machine:
$> cat src/openstack/identity.clj
Even though it seems like overkill (you could just as easily open the file in your editor), it’s small, unobtrusive, and strangely, not the default.