2

I was lead to believe that there were no differences between aliases in zsh and bash, however that appears to not be the case. I had an alias that would help me familiarize myself with the command line utilities available to me, but after copying it over to the new .zshrc of mine, it fails to work. I have confirmed that it's not an error by changing the alias, which resolved the issue.

The command is aliased to ?. Why can I not use ? when creating an alias?

alias ?='pwd'
alias ?='echo hello'

amongst others have been attempted. No alias mapped to ? has worked, as mentioned.

It is located in the ~/.zshrc file. I copied it from my .bashrc, as I have just decided to try zsh out.

  • 3
    What is the alias? We are not mind-readers you know !! – heemayl Apr 22 '16 at 17:15
  • 1
    Please edit your question and show us the exact line you used to define the alias, which file you placed it in, what happened when you ran it and what you expected to happen. We can't help you unless you tell us what you're doing. – terdon Apr 22 '16 at 17:23
4

? is special (being used by both glob and history expansion, see zshexpn(1)), and thus requires escaping, but otherwise can be used as an alias, though probably should not be, given that it is special.

% alias \?='echo hi'
% ?
hi

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.