- 使用alias
- 显示定义的所有别名
alias
配置实例
alias vi="vim"
alias ll="ls -al --color=auto"
- 在配置文件中配置命令别名
vim ~/.bashrc
source ~/.bashrc
或者
vim ~/.bash_profile
source ~/.bash_profile
- 使用函数
在配置文件~/.bash_profile中加入
function sshp {
/usr/bin/ssh -p 2234 $* # $* 包含命令行的所有参数和选项
}
再来一个例子
function compssh {
/usr/bin/ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -c aes128-cbc $*
}