I have created an alias of a folder called 'htdocs alias' and when i type in terminal cd 'htdocs alias' or cd htdocs\ alias it doesnt work?

any reasons why this is happening? or any suggestions to help this?


Mac OS aliases are more similar to Windows shortcuts than to Unix symlinks; you can double-click them but you cannot cd into them.

This article explains how to make cd follow OS X aliases:

This is a two-part process requiring a little familiarity with gcc and bash, but I’ll try to make it as simple as possible. Firstly, you need this file: getTrueName.c. This file was created by Thos Davis and is licensed under the GPLv2. Save it anywhere, then compile it with the following command:

gcc -o getTrueName -framework Carbon getTrueName.c

This will create the ‘getTrueName’ executable in the same directory as the source. You can add it to your PATH, or just copy it directly to /usr/bin so it’s easy to access.

Interestingly, when Terminal opens a new shell, .bashrc is not executed as you might expect. Instead, under the login shell, .bash_profile is executed. So, add the following to .bash_profile in your Home directory. You might need to create it first; it isn’t there by default.

cd() {
  if [[ -f "$1" || -L "$1" ]]; then
    path=$(getTrueName "$1")
    builtin cd "$path"
    builtin cd "$@"

[edited the function a bit –grawity]

  • Alternatively, it's quite easy to create an OS X Service that creates symlinks and can be assigned the keyboard shortcut Cmd-L instead. – Daniel Beck Mar 6 '11 at 21:15
  • The linked article no longer exists. – Chris Page Jun 14 '12 at 23:23
  • Fixed, @ChrisPage. – user1686 Jun 15 '12 at 12:03
  • Are you sure == works? Shouldn't it be -eq? ${#1} also doesn't look right, $# should suffice... – Daniel Beck Aug 30 '12 at 9:44
  • @DanielBeck: I just quoted the entire article, hadn't really looked into the wrapper function. – user1686 Aug 30 '12 at 12:31

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.