A more colourful cat in your shell
I just wanted to quickly share a shell alias I have been using lately to get some more color in the terminal when you cat a file.
Below is a screenshot of what an average terminal looks like when you just use
$ cat somefile.js
Sure, it does the job, and you probably are ok with it looking dull as hell. But what if you could make it look like this:
Indeed! If you could, why wouldn't you?
So, let's get to it. Luckily this isn't very complex to get going on your machine. Let's start by installing Pygments. This little Ruby wrapper library is used to make the realtime syntax highlighting possible: bash
gem install pygments
Next up, the alias itself. Depending on your shell and environment open up your profile. If you aren't sure whether you've installed or configured something specifically on your system, chances are the file you are looking for (on OSX at least) is
In there, add the following alias:
alias c='pygmentize -O style=monokai -f console256 -g'
And that's all there is to it. Now whenever you type
c some-file.ext it will detect the extension and add syntax highlighting.
I chose the monokai style because it looks awesome and works well with the rest of my ZSH theme, but feel free to try a few and see which works best for you.