添加linux alias

有时候需要用alias做几个简单好记的命令方便快速输入

可以使用alias进行修改别名

在我的Ubuntu系统下 看一下 /etc/bash.bashrc 文件 在后面加入这个代码

# add the alias command
if [ -f /etc/aliasbashrc ]; then
    . /etc/aliasbashrc
fi

检测到 /etc/aliasbashrc 这个后就执行它让它能专门用来写别名alias

cat /etc/aliasbashrc

可以看到

alias gts="git status"
alias gct="git checkout"
alias gdf="git diff"
alias gad="git add"
alias grm="git rm"
alias gcm="git commit -m"
alias gft="git fetch"
alias grb="git rebase"
alias gph="git push"

保存 写入 source ~/.profile 导入一下。

然后命令行就可以使用 gts 代替 git status了 其他命令也一样。

原文地址:https://www.cnblogs.com/lizhaoyao/p/14361457.html