1

In my Finder windows I have many aliases that target other folders or documents. At the shell prompt in Terminal, these aliases show up as regular files. How can I get the target of an alias so that, for example, I can "cd" to it or perform other command-line operations on the alias target?

1

To enable cd'ing into an Folder Alias I've found the following at Mac OS X Hints. Don't know if it still works.

Here is the bash function I include in .bashrc. Note that the second elif requires double brackets for the test, because it include the logical operator or (||):

function cd {
  if [ ${#1} == 0 ]; then
    builtin cd
  elif [ -d "${1}" ]; then
    builtin cd "${1}"
  elif [[ -f "${1}" || -L "${1}" ]]; then
    path=$(getTrueName "$1")
    builtin cd "$path"
  else
    builtin cd "${1}"
  fi
}

And here's the C source code for getTrueName.

A similar approach is available at superuser.com

|improve this answer|||||
0

Maybe I'm off but ... Another approach would be simply to replace mac aliases by regular unix links via "ln -s ..". It has many advantages as Finder shows links as aliases but many applications works as if links were their target. Mac aliases are not always seen by applications as their target so that's also a good reason to prefer regular links… especially if you are used to terminal commands and want something really reliable at system level.

Only a suggestion and as already said, I may be far from your needs.

Hope it can help anyway. :D

|improve this answer|||||

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .