Add pwdf function and cdf alias for macOS users

This commit adds a new function 'pwdf' to get the current Finder
directory and an alias 'cdf' to change to that directory, improving
integration between Terminal and Finder for macOS users.
This commit is contained in:
Sami Samhuri 2024-08-27 13:47:53 -07:00
parent f6560c0d49
commit 8a6001587f
No known key found for this signature in database

17
zshrc
View file

@ -290,6 +290,23 @@ function cd () {
fi
}
if mac; then
# Courtesy of https://curtclifton.net/finder-and-terminal-are-friends
pwdf() {
/usr/bin/osascript <<" EOT"
tell application "Finder"
try
set currFolder to (folder of the front window as alias)
on error
set currFolder to (path to desktop folder as alias)
end try
POSIX path of currFolder
end tell
EOT
}
alias cdf='cd "`pwdf`"'
fi
### Unsorted (new) stuff
# =======================
# if commands takes more than 60 seconds tell me how long it took