unalias
removes / disables an alias for the current session, that is, an alias is temporally disabled. If an alias is wrong, undesired or no more useful, I simply delete it from .bashrc
or .bash_alias
and source ~/.bashrc
or close and reopen my terminal.
A usage I have found for unalias
was when, after creating an alias in my .bash_aliases, I decided to change the alias to a function.
That is, I have changed alias dothis="action"
to dothis () { echo "some text"; action1; action2; }
.
But source ~/.bashrc
kept on returning a syntax error near unexpected token ('
that I couldn't fix, until I figured out that the error was coming from the fact I was using the same name for the original alias and the newly created function (sounds like an obvious error but not so at first sight). The error was gone after I unaliased the original alias: unalias dothis
.
Besides this case, in which situations one would need / want to unalias
?