Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use Ccat under Linux

Shulou Source: shulou.com Published: 2022-06-01 05:17:24 09月13日 Update

This article mainly shows you "how to use Ccat under Linux", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to use Ccat under Linux" this article.

1. Install Ccat

1) the ccat command is available directly in AUR, so if you have an AUR assistant on your system, you can install it directly. Arch systems, for example, can be installed directly using the yay command.

The Arch user software repository, commonly referred to as the 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, as follows:

Download the source archive package using the following command

$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 system $PATH (for example, / usr/local/bin/)

$sudo cp linux-amd64-1.1.0/ccat / usr/local/bin/

Finally, use chmod to add executable permissions to the ccat command

$sudo chmod + x / usr/local/bin/ccat

two。 How to use ccat to shade cat commands

The method of using ccat is very similar to the cat command, so here are some examples.

Let's first look at the text file, such as hello.c, with the cat command.

$cat hello.c

The effect is as follows

Cat

You can see that the code does not have any color markings (you should be familiar with this result). Now, use ccat to look at the text file hello.c and see how it displays the output.

$cat hello.c

The effect is as follows:

Ccat

Have you noticed the difference? ccat uses syntax to highlight the output, while the cat command displays the output only in the system's default theme color.

We can also display the output of more than one file at a time, as shown below.

$ccat test.txt example.txt

For some reason, you may want to display the output in HTML format. To do this, simply add the "- html" option at the end.

$ccat test.txt-html

Not only the local file, we can also display the contents of the file directly on the network as follows.

$curl https://raw.githubusercontent.com/jingweno/ccat/master/main.go | ccat

To see the default code color, 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 error during the download step

Ccat_error

This is because github upgraded openssl and disabled tlsv1.1. You only need to update the native 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, all you need to do is create an alias.

If you installed it from AUR in Arch Linux, add the following line to the ~ / .bashrc file.

Alias cat=ccat

If installed from a compiled binary, add the following line to the ~ / .bashrc file.

Alias cat=/usr/local/bin/ccat

Finally, run the following command for the changes to take effect.

$source ~ / .bashrc

To add it system-wide (this command is available to all users), add the above entry to the / etc/bashrc (on RPM-based systems) or / etc/profile (on Debian-based systems) file.

The above is all the contents of the article "how to use Ccat under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Commands files systems output content colors codes users articles assistants just need effects text steps software learning help compile run similar Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft Huawei macOS Shulou Technology