Skip to content

Instantly share code, notes, and snippets.

@shinvou
Created April 29, 2018 22:35
Show Gist options
  • Save shinvou/c7d43f36e0973de9df24c86a3da8fab7 to your computer and use it in GitHub Desktop.
Save shinvou/c7d43f36e0973de9df24c86a3da8fab7 to your computer and use it in GitHub Desktop.
Fish function to set current working directoy to Finder window path
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