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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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 % cd % dirs ~ /tmp
(I’m tempted to call that another argument against using the csh family of shells.)
Method 2
Don’t make aliases that clobber shell builtins. Your life will be much easier. There are plenty of key combinations left, try cw for your change window title alias 🙂
Edit: Two step solution for fixing alias that aren’t yours:
- Find the monkey who aliased
cdto something other than the change-directory command and request his transfer to the oped column of the local paper. He shouldn’t be holding a job where he can force ideas like that one onto other people’s shells! echo unalias cd >> ~/.bashrc
Method 3
prefix your command with the word ‘command’. Ex.
command ls
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0