Home > Back-end >  Why does zsh allow to use combination of aliases in git without space?
Why does zsh allow to use combination of aliases in git without space?

Time:10-22

I have the following alias defined for both bash and zsh:

alias g=git

Additionally, in git I configured the git alias alias.st status, so that I can get the git status with

g st.

Now I realized that in zsh, gst (without space) works as well. Any ideas as of how/why that happens? In bash, the same command leads to Command 'gst' not found.

CodePudding user response:

I haven't used vanilla zsh in a long time and personally don't think that zsh by itself knows about the gst command unless you manually specify it. If you are using the popular framework oh-my-zsh, it has a git plugin which defines some ~130 additional git aliases, some of which do include gst.

cat $HOME/.oh-my-zsh/plugins/git/git.plugin.zsh | grep "gst"
alias gst='git status'
alias gsta='git stash save'
alias gstaa='git stash apply'
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --text'

If you have enabled this plugin from your .zshrc, then by default you have access to this alias as well (and the other 129).

  • Related