Ccat – Colorize Cat Command Output
Ccat is available in AUR, so you can install it using any AUR helpers, for example Yay, in Arch Linux and its variants like below.
$ yay -S ccat
On other Linux distributions, you need to compile and install Ccat as shown below.
Download the latest ccat binary from here.
$ wget https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz
Extract the downloaded archive file:
$ tar xfz linux-amd64-1.1.0.tar.gz
Copy the ccat executable file to your system $PATH (for example, /usr/local/bin/):
$ 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:
$ cat test.txt
Now, view the text file with “ccat” and see how it displays the output.
$ ccat test.txt
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
$ ccat --palette
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 with ccat, 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.
$ source ~/.bashrc
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!!