loading...
Cover image for Add syntax highlighting to 'cat' in your terminal

Add syntax highlighting to 'cat' in your terminal

rogiervandenberg profile image Rogier van den Berg ・1 min read

I use my terminal everyday, and frequently I am way faster with it then navigating around with my mouse in Finder.

Within your terminal the cat command is very useful to quickly peek inside a file, but when you're looking at source code, this is a bit difficult to read. I just thought "Wouldn't there be syntax highlighting for my terminal?". As it turns out, there is. πŸŽ‰

How to set it up

  • With Brew, install Pygments: brew install pygments
  • Next, add the following to your .zshrc/.bashrc file: alias cat="pygmentize -g"
  • Open a new terminal window, or source your .zshrc file: source ~/.zshrc

Now, when you e.g. run cat Dockerfile on a Dockerfile, things look very neat!

Discussion

markdown guide
 

Thanks for sharing it!
There is also a similar tool called bat
github.com/sharkdp/bat