|
一、ls
对于ls输出,除了加上--color=auto这样的参数来接受系统默认的设置以外,我们可以为某种文件类型选择颜色。Fedora、Suse、Gentoo中一般都会有颜色的配置文件 /etc/DIR_COLORS 。在Debian/Ubuntu中如果没有的话,可以: # dircolors -p > /etc/DIR_COLORS 或者 # dircolors -p > ~/.dir_colors 但dircolors程序不会去主动识别配置文件,需要在~/.bashrc中写上: export LS_OPTIONS='-aCF --color=auto' eval "`dircolors -b /etc/DIR_COLORS`" alias ls='ls $LS_OPTIONS' 例如,设计一种特殊的文件结尾.É,并把这种文件的颜色在/etc/DIR_COLORS里写上: .É 01;36 # eval "`dircolors -b /etc/DIR_COLORS`" 这样作以后,环境变量LS_COLORS会按照颜色配置文件中的设置发生变化。于是,用ls就可以看到这种文件的颜色了。
二、PS1
下面这个PS1颜色是我的Gentoo中的默认设置: # export PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
三、grep
对于grep来说,加参数--colour=auto可以使用颜色: # alias grep='grep --colour=auto' 这种颜色也可以通过设置GREP_COLOR环境变量来调配: # export GREP_COLOR='1;37;41' ---红底白字
四、manpage
下面是从linuxsir论坛转来的某位仁兄的关于manpage的颜色的设置: 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'
|