Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Open a Terminal with either iTerm or Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open a Terminal with either iTerm or Terminal
Authored by: klktrk on Aug 21, '04 02:18:59AM

Okay, so I figured out how to do it with iTerm:


Open Terminal Here

A toolbar script for Mac OS X 10.3

Written by Marc Liyanage

See for
more information about toolbar scripts.

See for the latest
version of this script.

20-AUG-2004: Version 2.0.1 by Kristofer Widholm, can work with either iTerm or Terminal
18-AUG-2004: Version 2.0 by Allan Marcus. uses posix path
30-OCT-2001: Version 1.0, adapted from one of the example toolbar scripts
30-OCT-2001: Now handles embedded single quote characters in file names
30-OCT-2001: Now handles folders on volumes other than the startup volume
30-OCT-2001: Now handles click on icon in top-level (machine) window
31-OCT-2001: Now displays a nicer terminal window title, courtesy of Alain Content
11-NOV-2001: Now folders within application packages (.app directories) and has a new icon
12-NOV-2001: New properties to set terminal columns and rows as the Terminal does not use default settings
14-NOV-2001: Major change, now handles 8-bit characters in all shells, and quotes and spaces in tcsh
18-NOV-2001: Version 1.1: Rewrite, now uses a temporary file ~/.OpenTerminalHere to communicate
the directory name between AppleScript and the shell because this is much more reliable for 8-bit characters


property terminal_rows : 24
property terminal_columns : 90
property debug : true
property terminalApp : "iTerm" --set to "Terminal" if you'd rather use that.
-- when the toolbar script icon is clicked
on run
tell application "Finder"
set this_folder to (the target of the front window) as alias
on error
set this_folder to startup disk
end try
my process_item(this_folder)
end tell
end run

-- This handler processes folders dropped onto the toolbar script icon
on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
my process_item(this_item)
end repeat
end open

-- this subroutine processes does the actual work
on process_item(this_item)
set thePath to quoted form of POSIX path of this_item
if terminalApp is equal to "iTerm" then
tell application "iTerm"
set firstTerminal to (the first terminal)
on error
set firstTerminal to (make new terminal)
end try
tell firstTerminal
launch session "Default Session"

tell the last session

-- write some text
write text "cd " & thePath
end tell
end tell
end tell
else if terminalApp is equal to "Terminal" then
tell application "Terminal"
do script with command "cd " & thePath
tell window frontmost
set custom title to this_item
end tell
end tell
end if
end process_item

[ Reply to This | # ]