How do I expand commands within a bash alias?

十年热恋 提交于 2019-12-01 00:52:42

The immediate problem is that the command substations are expanded inside the double quotes when the alias is defined. Using single quotes will fix that by deferring the command substitution until you actually use the alias.

alias gup='git pull origin $(git rev-parse --abbrev-ref HEAD)'

However, you can save yourself the trouble of trying to get the quoting just right by using a shell function instead.

gup () {
    git pull origin $(git rev-parse --abbrev-ref HEAD)
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!