参考 :
http://blog.sina.com.cn//s/blog_a046022d0102v6fi.html
https://github.com/EthsonLiu/personal-notes/blob/master/config/mac/mac_config.md#%E7%BB%88%E7%AB%AF
我的配置
配置说明 : 用户名(黄色),mac名称(绿色),文件夹(蓝色),可执行文件(绿色),字体不加粗(一般不设背景色,于是将所有2变成x)
1. 打开终端,用如下命令进入配置文件(需要输入密码),按i进入编辑模式
sudo vim ~/.bash_profile
2. 添加以下其中一种配置即可
#启用颜色
export LS_OPTIONS='--color=auto'
export CLICOLOR='Yes'
export LSCOLORS='exfxhxhxcxhxhxgxgxexex'
export GREP_OPTIONS='--color=auto'
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#启用颜色
# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=exfxhxhxcxhxhxgxgxexex
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
export TERM="xterm-color"
PS1='\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ '
3. 按esc退出编辑模式, 输入 :wq 回车保存文件,并输入如下命令使配置文件生效
source ~/.bash_profile
4. 重启终端即可
自定义配置说明
颜色设置格式如下
export CLICOLOR=1
export LSCOLORS=1212121212121212121212
LSCOLORS共有11组”12”设置,每组12对应文件类型为
1. directory
2. symbolic link
3. socket
4. pipe
5. executable (可执行文件,x权限)
6. block special
7. character special
8. executable with setuid bit set (setuid=Set User ID,属主身份)
9. executable without setgid bit set
10. directory writable to others, with sticky bit
11. directory writable to others, without sticky bit
字母代表的颜色如下:
a black
b red
c green
d brown
e blue
f magenta
g cyan
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background (透明)