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:
parent
f6560c0d49
commit
8a6001587f
1 changed files with 17 additions and 0 deletions
17
zshrc
17
zshrc
|
|
@ -290,6 +290,23 @@ function cd () {
|
||||||
fi
|
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
|
### Unsorted (new) stuff
|
||||||
# =======================
|
# =======================
|
||||||
# if commands takes more than 60 seconds tell me how long it took
|
# if commands takes more than 60 seconds tell me how long it took
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue