Linux Color

来源:互联网 发布:软件质量品质管理 编辑:程序博客网 时间:2024/04/29 16:08
http://www.cnblogs.com/zackyang/archive/2010/03/23/1692830.html

1、将下面的代码拷贝到~/.bash_login中,可以让man有颜色

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'

## 指定less为默认阅读器
export PAGER=less

2、让ls有颜色显示,可以在~/.bash_profile中加入:

alias ls=’/bin/ls --color=auto’  ## 如果ls已经是有彩色输出了, 可忽略

3、让grep可以高亮选择的关键字,可以在~/.bash_profile中加入:

alias grep='grep --color'    ## 这个是强烈推荐的, 用过多后肯定会喜欢

4、解释一下各个配置文件的读取顺序:

    当一个login bash 启动后, (如ssh 登录成功后, 或 bash –login 运行时), login bash将会按以下逻辑去读取配置文件

[[ -r /etc/profile ]] && source /etc/profile

if [[ -r ~/.bash_profile ]]; then

       source ~/.bash_profile

elif [[ -r ~/.bash_login ]]; then

       source ~/.bash_login

elif  [[ -r ~/.profile ]]; then

       source ~/.profile

fi

    当一个非login 且是interactive的 bash启动时, (如执行bash并回车)  ## 如果对login bash, interactive bash的概念不清, 可找俺详谈, 或man bash Bash将按以下逻辑去读取个人配置

[[ -r ~/.bashrc ]] && source ~/.bashrc

值得注意的是, 一个login bash并不会去执行 [[ -r ~/.bashrc ]] && source ~/.bashrc

0 0
原创粉丝点击