Friends who have used the Linux system must have used the The But for programmers, the problem with cat command is that its output does not have any color marking. If we use the cat command to view the code file, it is really inconvenient to read without color marking of keywords. In order to solve this pain point, a big guy developed the The following is a detailed introduction to the usage of ccat. 1. Install Ccat 1) Arch User Repository is commonly referred to as AUR. AUR Helper is a wrapper that allows users to install packages from the AUR repository without manual intervention. $ yay -S ccat 2) In other Linux distributions, you need to compile and install ccat, the steps are as follows: Use the following command to download the source archive compressed package $ wget https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz Unzip the downloaded archive $ tar xfz linux-amd64-1.1.0.tar.gz Copy the ccat executable to your system $ sudo cp linux-amd64-1.1.0/ccat /usr/local/bin/ Finally, use chmod to add executable permissions for the ccat command $ sudo chmod +x /usr/local/bin/ccat 2. How to use ccat to colorize the cat command The usage of ccat is very similar to the cat command. Here are some examples. Let's first use the cat command to view a text file, such as hello.c. $ cat hello.c The effect is as follows You can see that the code does not have any color marking (this result should be familiar to everyone). Now, use ccat again to view the text file hello.c and see how it displays the output. $ ccat hello.c The effect is as follows: Did you notice the difference? ccat displays the output with syntax highlighting, whereas the cat command simply displays the output in the system's default theme colors. We can also display the output of multiple files at a time as shown below. $ ccat test.txt example.txt For some reasons, you may want to display the output in HTML format. To do this, just add the “--html” option to the end. $ ccat test.txt --html Not only local files, we can also display the contents of files directly on the network as shown below. $ curl https://raw.githubusercontent.com/jingweno/ccat/master/main.go | ccat To see the default code coloring, run the following command. $ ccat --palette Of course, you can set your own color code as follows. $ ccat -G String="_fuchsia_" -G Plaintext="darkteal" hello.c ps: You may encounter the following errors during the download step This is because GitHub upgraded OpenSSL and disabled TLSv1.1. You only need to update the local OpenSSL and Git tools to solve the problem. 3. Replace cat in the system If you like ccat and want to replace the default cat command with ccat, just create an alias. If you installed from AUR in Arch Linux, add the following line in your alias cat=ccat If you installed from compiled binary, then add the following line in your alias cat=/usr/local/bin/ccat Finally, run the following command for the changes to take effect. $ source ~/.bashrc To add it system-wide (all users can use this command), add the above entry in This is the end of this article about a colorful "cat" under Linux. For more relevant content on the usage of linux ccat, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! |
<<: How to implement scheduled backup of CentOS MySQL database
>>: Examples of using provide and inject in Vue2.0/3.0
Git is integrated in vscode, and many operations ...
This article records the specific method of insta...
What is the difference between the green version ...
Preface I wrote a small demo today. There is a pa...
MySQL database storage location: 1. If MySQL uses...
Nginx's shared memory is one of the main reas...
1. Concept Analysis 1: UE User Experience <br ...
This article uses examples to illustrate the usag...
Table of contents Install Docker-ce for the devel...
Table of contents 1. What is Docker Compose and h...
When using docker, you may find that the file can...
For historical reasons, MySQL replication is base...
How do I download MySQL from the official website...
Preface tcpdump is a well-known command-line pack...
Preface In the application of database, programme...