Skip to content

Instantly share code, notes, and snippets.

@BaksiLi
Created January 2, 2020 15:34
Show Gist options
  • Save BaksiLi/7e66c1f42dcd49821b88bd4d942c0f09 to your computer and use it in GitHub Desktop.
Save BaksiLi/7e66c1f42dcd49821b88bd4d942c0f09 to your computer and use it in GitHub Desktop.
Shell function cd for macOS alias
# Function for macOS alias
cda () {
thePath=`osascript <<EOD
set toPath to ""
tell application "Finder"
set toPath to (POSIX file "$1") as alias
set theKind to kind of toPath
if theKind is "Alias" then
set toPath to ((original item of toPath) as alias)
end if
end tell
return posix path of (toPath)
EOD`
builtin cd "$thePath" >> /dev/null 2>&1;
} >> /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment