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
Special note: Only the Swoole extension is instal...
The syntax for an outer join is as follows: SELEC...
need: Merge identical items of one field and sort...
Table of contents Scenario Try to solve solve Sce...
I think the commands I use most often are: Choice...
Overview In the previous chapter, we learned abou...
Table of contents The effect of mixed inheritance...
Table of contents 1 The common rules for creating...
The establishment of MySQL index is very importan...
1. InnoDB storage engine must be used It has bett...
1. ip_hash: ip_hash uses a source address hash al...
Preface When using the MySQL database, sometimes ...
Update: Recently, it was discovered that the serv...
Table of contents Common compression formats: gz ...
Table of contents Preface 1. Null coalescing oper...