Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just installed Oh My ZSH on my Mac. Everything is working great, except I can't define aliases with numerical names.

If I execute

alias 5="cd ~/Projects/Projectname/"

I get the following error message:

cd:cd:10: no such entry in dir stack


cd ~/Projects/

works as expected.

This only seems happen with numerical aliases. Any ideas why this isn't working?

share|improve this question

migrated from Feb 24 '13 at 2:34

This question came from our site for professional and enthusiast programmers.

Well, I just tried and it worked for me. Maybe you have spaces in projectname ? – MPogoda Feb 23 '13 at 21:01
Also, try copy&paste what your alias should do into zsh prompt – MPogoda Feb 23 '13 at 21:02
wow, weird. what does alias 5 tell you? i think this error should only happen if you do e.g. cd +3 or cd -4, which you're clearly... not – Eevee Feb 23 '13 at 21:03
call which 5 and post the results – Francisco Mar 5 '13 at 19:19

Probably, the set-up of "oh-my-zsh" is creating a function or alias with value/name 5 to cd -5.

Call which 5 to verify that.

share|improve this answer

Assigning a number as an alias of a command works perfectly fine. In fact, my oh-my-zsh uses the alias 5='cd +5' by default.

I cannot reproduce your error, but I suspect your problem is that cd is either a function or an alias that's somehow incompatible with the alias you've defined. You can check with the command which cd if this is the case.

If I'm right, defining the alias as

alias 5='builtin cd ~/Projects/Projectname'

should solve your problem, since it will execute the built-in cd command.

share|improve this answer
if oh-my-zsh adds such an alias, then: 1. he has that alias set; 2. the error comes because his dirstack still lacks a 5th entry. – Francisco Mar 6 '13 at 8:27
The error message searches for the tenth entry, and alias 5="cd ~/Projects/Projectname/" should overwrite any previously defined aliases of 5. – Dennis Mar 6 '13 at 10:06

You must log in to answer this question.