How to Temporarily Bypass an Alias in tcsh

aliasshelltcsh

I am using tcsh. bash and zsh and other suggestions won't help here.

I have several aliases that are named the same thing as another command, so if I did unalias it, typing the same thing would now do something different.

Most of the time I want the aliased command, which is why I have them. However, sometimes I want the unaliased command.

Without actually unaliasing and redefining the command, is there a simple way to tell tcsh to use the unaliased command instead?

For example, vi is aliased to vim, but sometimes I want to just use vi. cd is aliased to change my window title, but sometimes I want to leave it alone.

Obviously I could type /usr/bin/vi but since cd is a shell built-in command, there is no equivalent. Is there a general solution?

Best Answer

You can use a backslash:

% alias ls ls -a
% ls
# ls -a output here
% \ls
# plain ls output here

For shell builtins, there turns out to be a gotcha: a leading backslash prevents both aliases and builtins from being used, but an internal backslash suppresses aliasing only.

% alias cd pushd
% cd /tmp
/tmp /tmp 
% c\d
% dirs
~ /tmp

(I'm tempted to call that another argument against using the csh family of shells.)

Related Question