Skip to content

Instantly share code, notes, and snippets.

@cmittendorf
Created August 31, 2014 10:37
Show Gist options
  • Save cmittendorf/415afb4ac880acce7f3e to your computer and use it in GitHub Desktop.
Save cmittendorf/415afb4ac880acce7f3e to your computer and use it in GitHub Desktop.
Open a Terminal window with the front Finder window as path.
on run
tell application "Finder"
activate
try
set this_folder to (the target of the front window) as alias
on error
set this_folder to startup disk
end try
my open_terminal_window(this_folder)
end tell
tell application "Terminal"
activate
end tell
end run
on open finder_items
repeat with this_item in finder_items
my open_terminal_window(this_item)
end repeat
end open
on open_terminal_window(finder_item)
set path_to_open to POSIX path of finder_item
repeat until path_to_open ends with "/"
set path_to_open to text 1 thru -2 of path_to_open
end repeat
tell application "Terminal"
do script with command "cd " & quoted form of path_to_open
end tell
end open_terminal_window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment