Skip to content

Instantly share code, notes, and snippets.

@myfavouritekk
Created August 22, 2014 13:00
Show Gist options
  • Save myfavouritekk/e99915c54c61e9819511 to your computer and use it in GitHub Desktop.
Save myfavouritekk/e99915c54c61e9819511 to your computer and use it in GitHub Desktop.
OS X: Change directory in Terminal, Sync folder in Finder window.
# change directory and sync Finder window
sd () {
# change terminal directory
cd "$@" || return
# sync Finder window or open new one if not exists
osascript -e "tell application \"Finder\"
if front Finder window exists then
set target of front Finder window to (""\"$PWD\""" as POSIX file)
else
open (""\"$PWD\""" as POSIX file)
end if
end tell" > /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment