How to prettify your cat command

A guide on how to make your old black and white cat command pretty and more legible

I have always used the cat command to quickly preview some files or to copy the contents of them to a clipboard. The second part was always working great, but previewing a let's say JavaScript file or RC file was painful, because of the lack of syntax highlighting.

I was too lazy to search for solutions, but my colleague recently showed me something called bat, which is a cat, but on steroids. Here's a little preview of what it looks like:

Preview of bat command

Installation and theme setup

You can install it through brew, just like this:

$ brew install bat

and if you don't like the default theme, you can choose some that are installed out of the box or install the custom one. I decided to use Nord, which was already installed, here's how I did it:

$ mkdir ~/.config/bat
$ sudo vim ~/.config/bat/config # remember to run it in sudo mode

then paste this line into the config

--theme="Nord"

and exit vim with :wq and you're done!

P.S you can still copy the contents of the file with bat something.txt | pbcopy! 🤠


Published on February 24, 2023 • 1 min read