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


Click here to return to the 'Opening new Terminal window from Finder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Opening new Terminal window from Finder
Authored by: larsonm on Apr 24, '11 10:16:47AM

Hello!

I'm a seasoned shell script writer who needs newbie advice on modifying this applescript.

I have long been using iTerm, and I've always wanted "Open a Terminal Window Here" from the Finder.

I'm thankful for your solution, and I figured I could easily modify it to use the app "iTerm" vice "Terminal", but I get an unexpected error that I don't know how to fix:

Syntax Error. Expected end of line but found "script".

Do I have to register iTerm somehow? Does a TTY app need to be instrumented with applescript for this to work, ie: understand "do script ...". Again -- please excuse my ignorance.

I could research this with vigor and learn applescript more, but I'm sure one of you has a very quick solution for me.

Code cut/pasted here:

===============================================
on ApplicationIsRunning(appName)
tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
return appNameIsRunning
end ApplicationIsRunning

tell application "Finder"
try
set winLoc to target of the front window as text
on error
set winLoc to home as text
end try
set pth to quoted form of POSIX path of winLoc
end tell

if ApplicationIsRunning("iTerm") then
tell application "iTerm"
do script "cd " & pth & ""
end tell
else
tell application "iTerm"
activate
set twID to index of front window
end tell
tell application "iTerm"
do script "cd " & pth & "" in window twID
end tell
end if

tell application "iTerm" to activate
===============================================


Thanks in Advance,
matt



[ Reply to This | # ]