热门搜索 :
考研考公
您的当前位置:首页正文

配置linux下dircolors,ls命令和mac下iTerm

来源:东饰资讯网

Linux下的ls --color=auto
命令,其实是根据两个文件来显示颜色的,/etc/DIR_COLORS 或者 ~/.dir_colors,一个是系统级别的配置文件,一个用户级别的配置文件。

cd ~
wget --no-check-certificate 
#or
#wget 
mv dircolors.ansi-universal ~/.dir_colors
eval `dircolors ~/.dir_colors`
cat >> ~/.bashrc
<<ALLEND########################################
if [ -x /usr/bin/dircolors ]; then 
alias ls='ls --color=auto' 
alias dir='dir --color=auto' 
alias vdir='vdir --color=auto' 
alias grep='grep --color=auto' 
alias fgrep='fgrep --color=auto' 
alias egrep='egrep --color=auto' 
alias tree='tree -C'
fi
########################################ALLEND
source ~/.bashrcls

iTerm2的配置

这里需要补充一点的是,mac 下的ls命令不是gun ls,所以即使iterm2安装了颜色主题,敲入ls命令以后,显示的文件颜色还是有问题的,这里有一个补救办法,运行下面这行,之后再看ls命令的颜色是不是变了
export LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD
但是,这种补救办法也不完美,比如不能根据文件类型来显示颜色。
如果你想追求完美的话,还有另外一种办法,就是用 brew install coreutils
,安装 gun ls命令到mac下,到时你还需要跟上面在linux下操作的一样,下载配置文件,放入到~/.dir_colors

Top