How to become a "lust" of UNIX systems

Source: Internet
Author: User
Tags definition color representation command line regular expression

First familiarize yourself with the "generic" representation of color codes:

For two-digit numbers:

The first digit, 3, defines the foreground color, and 4 represents the background color.

The second digit defines the specific color. 1 is red, 2 is green, 3 is blue, and 0 is black.

For example: 31;40m indicates that the foreground is red and the background color is black.

The foreground background color is separated by; The end of the definition in character M, and the current setting if there is no definition for the foreground or background. A single digit of 0 indicates a darker color, and 1 indicates a lighter color, which is brighter and darker than the foreground.

The above mentioned "General" is the general character terminal driver understood by the color code representation, of course, the color representation must be a relatively few occurrences of a special character sequence began. This sequence is:

[[27 of ^['s ASCII, which is the value entered by escape, needs to be entered with 〈C-V〉ESC on the terminal command line.)

Here is where we can become lustful:

1. Prompt string for command line

To define the color here, you must pay attention to the beginning of the special sequence. Indicates the end of a special sequence, or the terminal driver incorrectly calculates the space in which the hint string should occupy as many characters as the ^[[31;40m so many characters do not occupy the output space on the screen, only to change the color.

2. LS--color

Initial lascivious talent will honestly input long--color, old goat used to hide himself with the alias.

Specific what file with what color display to see the content of ls_colors environment variables, this environment variable content is really long, but the definition of it does not need one to knock in, Dircolors command can read from the/etc/dir_colors in a readable form of color customization scheme, Then convert to a compressed version of the environment variable, note that dircolors output is a command, the command itself needs your current shell to execute before it takes effect.

Eval "$ (dircolors/etc/dir_colors)" is required to add ls_colors variables to your current environment. Executing it in a child shell will not benefit the parent process.

3. grep--color

I've thought about adding a feature that highlights its color support for the Black-and-white era grep and doesn't want to be implemented before me. This may not be part of POSIX's specification for grep, but it's a lot of benefits, especially for people who start with regular expressions, not only do you get a matching line, but it also shows you in a bold way which part of the line matches your regular expression and will be matched to grep-p ' ab+ ' << output is abbbbbbbbbbbbb.

It's all red from beginning to end.

The output is also

abbbbbbbbbbbbb

Only the beginning of Ab two characters character character is red.

4. Coloring for any output

grep displays only those rows that match, or does not match, so it cannot display those unmatched rows at the same time, for example, the following is the output of CVS:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.