mac os 下面的命令别名设置
在linux上用ll命令习惯了,所以在mac上我也习惯用ll,但是这个命令是不存在的,它只是ls -l的一个别名,因为mac下面没有默认设置别名。
sudo vi /etc/bashrc
在文件最后添加如下代码
# MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
# Terminal colours (after installing GNU coreutils)
NM="\[\033[0;38m\]" #means no background and white lines
HI="\[\033[0;37m\]" #change this for letter colors
HII="\[\033[0;31m\]" #change this for letter colors
SI="\[\033[0;33m\]" #this is for the current directory
IN="\[\033[0m\]"
export PS1="$NM[ $HI\u $HII\h $SI\w$NM ] $IN"
if [ "$TERM" != "dumb" ]; then
#export LS_OPTIONS='--color=auto'
eval `dircolors ~/.dir_colors`
fi
# Useful aliases
alias ls='ls $LS_OPTIONS -hF'
alias ll='ls $LS_OPTIONS -lG' #加入G参数表示出现颜色区分
alias l='ls $LS_OPTIONS -lAhF'
alias cd..="cd .."
alias c="clear"
alias e="exit"
alias ssh="ssh -X"
alias ..="cd .."
操作完成后需要执行命令source /etc/bashrc
这个配置是所有用户适用,如果只配置当前用户,就编辑当前用户目录下的.bashrc文件
在.bashrc中可以对ll列出来的文件进行颜色设置
export CLICOLOR=1
export LSCOLORS=gxfxaxdxcxegedabagacad
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。
LSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
directory
symbolic link
socket
pipe
executable
block special
character special
executable with setuid bit set
executable with setgid bit set
directory writable to others, with sticky bit
directory writable to others, without sticky bit
LSCOLORS中,字母代表的颜色如下:
a 黑色
b 红色
c 绿色
d 棕色
e 蓝色
f 洋红色
g 青色
h 浅灰色
A 黑色粗体
B 红色粗体
C 绿色粗体
D 棕色粗体
E 蓝色粗体
F 洋红色粗体
G 青色粗体
H 浅灰色粗体
x 系统默认颜色
所以,如果我们想把目录显示成红色,就可以把LSCOLORS设置为bxfxaxdxcxegedabagacad就可以了
十佳人物