bat is cat on redbull.
no, seriously.
I recently discovered bat, a modern cat
alternative written in, yes, the Rust programming language. It comes with a plethora of features like syntax highlighting, git integration and automatic paging which replaces the dull, ugly output of cat
.
Installation
The various installation methods are listed in their readme. bat
works out of the box on every platform. Windows requires extra configuration for a few features.
Using bat
Like cat
, bat
works in the same way so all you have to do is type in bat filename
. Do note that on some distros like Ubuntu and Debian it is called batname
to avoid a name clash with another package. You can create an alias to define it back to bat
.
The decorations can be turned off with -n
to display only line numbers.
There are tons of different features like printing a specified range of lines, setting themes, adding or changing filetype associations, adding new language definitions and changing output styles. It works with several other tools like xclip
, fd
, git diff
to enhance their results. To get a list of all the options and commands, run cat --help
or man cat
and look at their docs.
The git
integration allows you to see modifications in the file with respect to the index.
All your configurations are saved neatly in a config file. To find the path to your bat.conf
and make changes to it, run bat --config-file
.
bat
is a cool, useful, and really fast tool for you to try out and maybe even switch to. A shoutout to the author sharkdp who has also authored popular and open-source tools like fd, hyperfine, pastel and many, many more. Check out his website and you will surely find something useful for you!
That’s all I have for you today and I will see you in the next one.