
They reuse the frontmost tab if it is not busy, e.g.They use the folder on the title bar instead of requiring you to select a folder first.The first two scripts have two advantages compared to the services added in 10.7:

Tell (launch session "Default") of result to write text "cd " & quoted form of p Tell application "System Events" to keystroke "t" using command downĪlways create a new tab (iTerm 2): tell application "Finder" to set p to POSIX path of (insertion location as alias)

Reuse an existing tab or create a new tab (Terminal): tell application "Finder" to set p to POSIX path of (insertion location as alias) If (exists window 1) and not busy of window 1 thenĭo script "cd " & quoted form of p in window 1 Reuse an existing tab or create a new window (Terminal): tell application "Finder" to set p to POSIX path of (insertion location as alias) You could also assign a shortcut to a script like the ones below. The former also understands man page references ("open(2)"), man page command line arguments ("2 open") and man page URLs ("x-man-page://2/open").Ĭd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')" On a related note, Lion Terminal also has new Services for looking up man pages: Open man page in Terminal displays the selected man page topic in a new terminal window, and Search man Pages in Terminal performs "apropos" on the selected text. This is the command-line equivalent of dragging a folder/pathname onto the Terminal application icon. You can also do this from the command line or a shell script: open -a Terminal /path/to/folder (Dragging into the terminal view within the tab merely inserts the pathname on its own, as in older versions of Terminal.) In addition, Lion Terminal will open a new terminal window if you drag a folder (or pathname) onto the Terminal application icon, and you can also drag to the tab bar of an existing window to create a new tab.įinally, if you drag a folder or pathname onto a tab (in the tab bar) and the foreground process is the shell, it will automatically execute a "cd" command. Go back to the parent folder, select the relevant folder, then activate the service via the Services menu or context menu. You cannot simply have the folder open and run the service "in place". The New Terminal at Folder service will become active when you select a folder in Finder. Services appear in the Services submenu of each application menu, and within the contextual menu (Control-Click or Right-Click on a folder or pathname). You can even assign command keys to them. These Services work in all applications, not just Finder, and they operate on folders as well as absolute pathnames selected in text. There's also New Terminal Tab at Folder, which will create a tab in the frontmost Terminal window (if any, else it will create a new window). System Preferences > Keyboard > Shortcuts > ServicesĮnable New Terminal at Folder.

As with most Services, these are disabled by default, so you'll need to enable this to make it appear in the Services menu.
OPEN IN TERMINAL MAC MAC OS X
As of Mac OS X Lion 10.7, Terminal includes exactly this functionality as a Service.
