Shell – Clear or disable aliases in zsh

aliasoh-my-zshshellzsh

I installed oh-my-zsh to make terminal use a bit easier. One thing that bugs me though is the prolific aliases added by it, like "ga", "gap", "gcmsg", "_", which are harder to remember than the original command, and pollutes the command hash table.

So is there a way to disable aliases altogether? Or a way to clear all aliases so that I can put it in my .zshrc?

Best Answer

If you don't want any of oh-my-zsh's aliases, but you want to keep other aliases, you can save the aliases before loading oh-my-zsh

save_aliases=$(alias -L)

and restore them afterwards.

eval $save_aliases; unset save_aliases

If you want to remove all aliases at some point, you can use unalias -m '*' (remove all aliases matching *, i.e. all of them).

If you absolutely hate aliases and don't want to ever see one, you can make the alias builtin inoperative: unalias -m '*'; alias () { : }. Or you can simply turn off alias expansion with setopt no_aliases.

Related Question