Syntax Highlighted Cat

I was setting up my work mac the other day and finally got round to implementing an alias for syntax highlighting the cat bash command. It’s very quick and simple.

Firstly, install pygments. Brew won’t work so you’ll need to run:

easy_install Pygments

(I was required to use sudo for the above command but you ought not yourself. This was due to using a computer provided by work which had restricted write permissions for non root users.)

<!– Also, as Keir pointed out to me in the comments, "If you’ve installed python with home­brew… you can sim­ply do: pip install Pygments“.  In this instance, I hadn’t –>

After that just throw a convenient alias in your .bashrc and you’re away:

alias c='pygmentize -O style=monokai -f console256 -g'
Every loves a good cat gif
Every loves a good cat gif

2 thoughts on “Syntax Highlighted Cat”

  1. Just a quick heads-up: pip is the preferred way to install python packages now, rather than easy_install. Also, both pip and easy_install shouldn’t be ran with sudo for security reasons.

    If you’ve installed python with homebrew (it gives you a more up-to-date version than the one bundled with OS X), then python packages will go in a location where root permissions aren’t needed, so you can simply do:

    pip install pygment

  2. I take your point regarding the use of sudo and updated the post to reflect why I used it and why most shouldn’t. I couldn’t get pip install to work after installing python with homebrew so have left that out of the body of the article unless you want to add more explicit instructions.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s