I have an alias which is predefined by an oh-my-zsh plugin. -> % alias gcm gcm='git checkout master' I'd like to remove it, i.e. I'd like alias | pcregrep "\bgcm\b" return 1. I've tried with alias gcm='' but after that the alias is still existent.


You can remove an alias simply using:

$ unalias gcm
| improve this answer | |
  • 1
    will this unalias it forever or only for this session? – meteors Apr 25 '15 at 12:41
  • 1
    @meteors Each session starts with no aliases, then they get created via your scripts - so, it depends on what you have in them. – nomadcoder Jul 26 '15 at 10:04
  • Note that if you have a global alias, you need to quote the alias name like so: unalias 'gcm'. Otherwise, the alias is getting expanded before executing the unalias command. – Lukas Juhrich Mar 12 at 16:27

This other answer is correct but if you're adding the unalias gcm line to your .zshrc file, it must be done AFTER oh-my-zsh is sourced, or else it will be overwritten by the zsh defaults.

It would look something like the below in your .zshrc file:

source $ZSH/oh-my-zsh.sh

# must unalias all ZSH defaults here AFTER we source the above
unalias gcm
alias gcm="whatever you want"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.