By alias, I mean the folder shortcut created when you right-click a folder in Finder and select "Make Alias". I can traverse symbolic links in Terminal with cd
, but it doesn't work on aliases: bash: cd: example-alias: Not a directory
. Is it possible to change directory to an alias's destination in Terminal?
MacOS – How to go to alias from terminal
aliascommand linemacosterminal
Best Answer
To enable cd'ing into a folder alias I've found the following at Mac OS X Hints.
Compile the source code below with the following command:
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 or /usr/local/bin so it’s easy to access.
C source code for getTrueName (copy the text and save the file as getTrueName.c in your home directory):
Include the following in ~/.bash_profile or create a new file ~/.bash_profile with the following content:
You probably have to restart Terminal to load your modified .bash_profile.
Tested in Yosemite 10.10.2 & gcc 4.2 (Xcode 6.2) and it works.
A similar approach is available at superuser.com