alias别名的使用

1、使用help查看alias如何使用

alias: alias [-p] [name[=value] ... ]
    Define or display aliases.
    
    Without arguments, `alias' prints the list of aliases in the reusable
    form `alias NAME=VALUE' on standard output.
    
    Otherwise, an alias is defined for each NAME whose VALUE is given.
    A trailing space in VALUE causes the next word to be checked for
    alias substitution when the alias is expanded.
    
    Options:
      -p	print all defined aliases in a reusable format
    
    Exit Status:
    alias returns true unless a NAME is supplied for which no alias has been
    defined.

2、如果没有参数,alias会打印可以使用的alias的所有信息。

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
skyfall@Hi3516:~$ 

3、现在我添加一个clear的别名,需要进行如下设置:

alias cls=‘clear’

可以发现使用cls实现了clear相同的效果,如果想在全局生效,需要在配置文件中进行设置。

4、打开家目录下的.vimrc文件,插入上面的语句。

扫描二维码关注公众号,回复: 5472855 查看本文章

5、使配置生效

.  .bashrc

猜你喜欢

转载自blog.csdn.net/zxy131072/article/details/88035288
今日推荐