Add syntax highlighting to 'cat' in your terminal
Tech ·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!