Here are some zsh functions that allow you to 1) return the path of the original file or folder given the respective Finder alias on the command line, and 2) a cd function that changes directory into the original, given the alias.
In your ~/.zshenv file:
a2o () {
# Return original file path given Finder alias
# Finder alias must be specified as filename.ext\ alias
f="$1"
osascript <<-EOF
use scripting additions
try
tell application "Finder"
set p to "$f" as POSIX file as alias
return POSIX path of ((p's original item) as text)
end tell
on error errmsg number errnbr
if errnbr = -1700 then
log "Original file or folder" & return
end if
end try
return
EOF
}
acd () {
# change directory to original folder from Finder folder alias
# Finder alias must be specified as filename.ext\ alias, "filename.ext alias"
orig=$(a2o "$1")
# print ${orig}
[[ -d ${orig} ]] && cd ${orig}
}
This file is read when you first login to a zsh shell, and automatically makes the functions available to the command-line. In the following, I made a Finder alias to the apple.pdf document and stuffed the alias into a Test folder, or made an alias to a Desktop Test folder:
a2o ~/Desktop/Test/apple.pdf\ alias
/Users/$USERNAME/Desktop/apple.pdf
a2o ~/Desktop/apple.pdf
Original file or folder
acd ~/Desktop/Test\ alias
odin3: ~/Desktop/Test %
cd
acd ~/Desktop/Test
Original file or folder
odin3: ~ %