Use bat instead of cat - cli command

I came across a new Unix command that can replace the standard cat command used to out file content.

That command is bat.

Install for Linux (Ubuntu)

To install on Ubuntu install through apt.

sudo apt install bat

Please note that this will install the command as batcat instead bat if you are using Ubuntu because of a package clash but this can be fixed.

Create a symbolic link between the batcat and bat commands.

sudo ln -s /usr/bin/batcat /usr/local/bin/bat

Check the command file path to see if its working.

which bat

If /usr/local/bin/bat is output then it’s set up correctly.

Install for MacOS

This step uses brew which is required to be installed.

Use the brew install command to add it.

brew install bat

Check that the bat command is working, a directory should be returned.

which bat