Open a Terminal window at current Finder selection

Apr 26, '02 09:35:03AM

Contributed by: TomWoozle

I often want to do something in OS X and find that I need root when I have navigated to a specific location in the Finder. So then I would have to open the terminal and navigate to that same location (or drag the folder while holding command-option onto the Terminal icon in the dock).

Well, I finally got around to creating an Applescript that does it for me, here it is:

on run
tell application "Finder"
try
activate
set frontWin to folder of front window as string
set frontWinPath to (get POSIX path of frontWin)
tell application "Terminal"
activate
do script with command "cd \"" & frontWinPath & "\""
end tell
on error error_message
beep
display dialog error_message buttons¬
{"OK"} default button 1
end try
end tell
end run
Save the script as an application and drop it in the Finder toolbar (or in the Scripts folder or use one of the available utilities to assign it a keyboard shortcut) and then each window has a handy link to the terminal which will open a new window navigated to that folder. This saves duplication of effort and long drag and drop operations.

Comments (15)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020426093503563