Ls, PS1, grep, and manpage colors

Source: Internet
Author: User
Color of ls, PS1, grep, and manpage-Linux general technology-Linux programming and kernel information. For details, see the following. I. ls

For ls output, in addition to the -- color = auto parameter to accept the default settings of the system, we can select a color for a certain file type. Fedora, Suse, and Gentoo usually have color configuration files/etc/DIR_COLORS. If not, you can:
# Dircolors-p>/etc/DIR_COLORS or
# Dircolors-p> ~ /. Dir_colors
However, the dircolors program does not actively identify the configuration file ~ /. Bashrc:
Export LS_OPTIONS = '-aCF -- color = auto'
Eval "'dircolors-B/etc/DIR_COLORS '"
Alias ls = 'ls $ LS_OPTIONS'
For example, design a special file ending with. É and write the color of the file in/etc/DIR_COLORS:
. É 01; 36
# Eval "'dircolors-B/etc/DIR_COLORS '"
In this way, the environment variable LS_COLORS will change according to the settings in the color configuration file. Then, use ls to see the color of the file.

Ii. PS1

The following PS1 color is the default setting in my Gentoo:
# Export PS1 = '\ [\ 033 [01; 31m \] \ h \ [\ 033 [01; 34m \] \ W \ $ \ [\ 033 [00m \]'

Iii. grep

For grep, you can add the -- color = auto parameter to the color:
# Alias grep = 'grep -- color = auto'
You can set the GREP_COLOR environment variable to adjust the color:
# Export GREP_COLOR = '1; 37; 41' --- white on the red background

4. manpage

The following figure shows how to set the manpage color of a renxiong transferred from the linuxsir Forum:
Export LESS_TERMCAP_mb = $ '\ E [01; 31m'
Export LESS_TERMCAP_md = $ '\ E [01; 31m'
Export LESS_TERMCAP_me = $ '\ E [0m'
Export LESS_TERMCAP_se = $ '\ E [0m'
Export LESS_TERMCAP_so = $ '\ E [01; 44; 33m'
Export LESS_TERMCAP_ue = $ '\ E [0m'
Export LESS_TERMCAP_us = $ '\ E [01; 32m'

Author: j_fo's planet

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.