Question

When I add an alias to ~/.zshrc such as alias dir='cd ~/Desktop/somedir' and do source ~/.zshrc, it says "command not recognized 'cd " when trying to use the alias in iterm 2.

However if I create the alias inside of iTerm 2 and not the ~/.zshrc file, it does recognize it. Anyone knows why this happens?

Thanks!

Was it helpful?

Solution

It seems that the single-quotes in your ~/.zshrc are not recognized as such and thus zsh assumes that two aliases are given: The definition of dir='cd and a query of ~/Desktop/somedir' instead of dir='cd ~/Desktop/somedir'. (zsh allows for multiple alias definitons and queries in one command)

Most likely the single quotes you are using are not ' from ASCII (ASCII code 0x27) but some Unicode representation. Depending on your editor it is possible that they got replaced automatically when you edited your ~/.zshrc. To be sure use an text editor that doesn't do any such 'auto-magic' (unless you tell it). I think of nano, vim and/or emacs are available on recent OS X versions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top