Created
April 29, 2018 22:35
-
-
Save shinvou/c7d43f36e0973de9df24c86a3da8fab7 to your computer and use it in GitHub Desktop.
Fish function to set current working directoy to Finder window path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function finwin --description "Set shell working directory to frontmost Finder window path" | |
set script " | |
tell application \"Finder\" | |
if exists Finder window 1 then | |
set currentDir to target of Finder window 1 as alias | |
return POSIX path of currentDir | |
else | |
return | |
end if | |
end tell" | |
set finder_path (osascript -e $script) | |
if [ $finder_path ] | |
echo "Changing working directory"; | |
echo "-> $finder_path" | |
cd $finder_path | |
else | |
echo "You don't have any open Finder windows, sorry." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment