Ccat – Colorize Cat Command Output
Ccat is available in AUR, so you can install it using any AUR helpers in Arch Linux and its variants.
pacaur -S ccat
packer -S ccat
yaourt -S ccat
yay -S ccat
On other Linux distributions, you need to compile and install Ccat as shown below.
Download the latest ccat binary from here.
Extract the downloaded archive file:
tar xfz linux-amd64-1.1.0.tar.gz
Copy the ccat executable file to your bin folder to use system wide:
sudo cp linux-amd64-1.1.0/ccat /usr/local/bin/
Finally, make it executable using command:
sudo chmod +x /usr/local/bin/ccat
The usage is very similar to cat command. Let me show you some examples.
To view a text file, for example test.txt, using cat command, we use:
Now, view the text file with “ccat”.
Did you notice the difference? ccat displays the output with syntax highlighting whereas cat command simply displays output in the system’s default theme color.
We can also display the output of multiple files (i.e concatenate) at once like below.
ccat test.txt example.txt
For some reason, you may want to display the output in HTML format. To do so, just add “–html” option at the end.
ccat test.txt --html
Not just local files, we can also directly display the contents of a file in the web like below.
curl https://raw.githubusercontent.com/jingweno/ccat/master/main.go | ccat
To view the default applied color codes, run
You can, of course, set your own color codes like below.
ccat -G String="_fuchsia_" -G Plaintext="darkteal" test.txt
If you like ccat and wanted to replace the default cat command, just create an alias.
If you installed it from AUR in Arch Linux, add the following line in your ~/.bashrc file.
If you installed it from the compiled binary file, add the following line in ~/.bashrc file.
Finally, run the following command to take effect the changes.
To add it system wide, add the above entry in /etc/bashrc (On RPM based systems) or /etc/profile (on Debian based systems) file.
And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!