How can I cd to an alias directory in the Mac OSX terminal

前端 未结 7 510
迷失自我
迷失自我 2021-01-29 23:49

Is there a way to get into an alias directory from shell with the command \"cd\" ? It always returns that \"htdocs\" isn\'t a directory.

Edit: I made the shortcut with t

相关标签:
7条回答
  • 2021-01-30 00:42

    You may be able to use osascript to do this -- this command seems to work:

    cd "`osascript -e "on run aFile" -e "set aFile to POSIX file aFile as alias" -e "tell application "\""Finder"\"" to return POSIX path of ( ( original item of aFile ) as text ) " -e "end run" path_to_my_Finder_alias 2>/dev/null`"

    Basically this command is running an AppleScript that finds the destination path of the argument (path_to_my_Finder_alias) in a subshell, then wraps it in double quotes, and changes the directory to it.

    Maybe someone with a little more bash expertise can turn it into a bash alias or function.

    0 讨论(0)
提交回复
热议问题