I created this command: kat
based on GNU cat, but with syntax highlighting. It was made with C++.
I classified it as:
“A cat command, but almost with a chocolate flavor” (slogan)
A reference to the KitKat chocolate! And almost because it doesn’t have the
Kit😃
The kat
command is still under development, so not all syntaxes are available. At the end of this article there are those that are already and those that are yet to be implemented, in addition to other features that I want to implement.
It’s been a while since I created it, but now I’ve decided to make it available for anyone who wants to use it. It’s based on other similar commands that I’ve seen, but I didn’t like them as much and I needed it to be:
The other similar commands were missing something, such as: source-highlight(also made with C++, but not very nice looking), Theldus/kat
(made in C, but I didn’t like the look either), bat(initially made with Go/Golang, it used to be quite fast, but then it was rewritten in another language and became very slow, besides having too many features for a cat command), highlight(made with Lua and C++, it is also more than a simple cat command, it has many other features).
Theldus/kat
has also made a comparison with bat
(very slow) and cat
. terroo/kat
is in the same performance line, that is, since it is an immediate utility, it needs to be fast:
Anyway, I was left with creating my own solution!
kat
?kat
is currently only available for UNIX-style systems. So, to compile beforehand you need some dependencies, which are:
You can use your system’s package manager and install, for example, on Ubuntu:
sudo apt update
sudo apt install build-essential cmake libboost-regex-dev
Then just clone, build and install:
git clone http://github.com/terroo/kat build-kat
cd build-kat
cmake -B build .
cmake --build build
sudo cmake --install build
After installing, you can remove the cloned directory:
cd .. && rm -rf build-kat
.
kat
?Just like you use cat
, the difference is that it already has line numbering, so it doesn’t need an additional parameter, examples:
kat main.cpp # C++
kat main.c # C
kat MyClass.java # Java
kat script.py # Python
kat index.js # JavaScript
kat Main.cs # C#
kat.txt # Text
The output will be similar to the image below:
As I said, there aren’t many parameters available, who uses all the cat
parameters, for example? I think the most I’ve ever used in my life was -n
to see the line numbers.. 😃
So, to see the kat
help
, just run:
kat --help
You’ll be amazed at the amount of parameters!!! 🤣
As I said, it’s still under development, so the languages and formats that have ✔ are available and those that have ✖ are yet to be implemented.
But, if you want to speed up the implementation of any of them, submit an issue in the kat repository.
In addition to implementing in the future: Ruby, PHP, Elixir, Perl, Zig, Rust, Erlang, Haskell and others.
I hope you like kat
, ahhh… leave a ✰ in the repository! 😎