Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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/"
5

I get the following error message:

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

Executing

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 stackoverflow.com 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
2  
call which 5 and post the results –  Francisco Mar 5 '13 at 19:19

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.