Is there a way to modify the Open Terminal command so that it uses tabs with Terminal.app? I have been trying to do this but my applescript-fu is weak. :/
Best, Mark
On 17 Apr 2008, at 02:52, Mark Eli Kalderon wrote:
Is there a way to modify the Open Terminal command so that it uses tabs with Terminal.app? I have been trying to do this but my applescript-fu is weak. :/
I see there is plenty of support for this in the scripting dictionary, but I also don’t get AppleScript.
I tried first:
tell app "Terminal" to return tabs of first window
This worked fine, so then I tried:
tell app "Terminal" to make new tab in first window
That gave me:
Terminal got an error: Can’t make or move that element into that container. (-10024)
And then I gave up :)
On 4/21/08 8:36 AM, in article 0F70886B-FCF9-4318-A398-9D5CBA91F0B0@macromates.com, "Allan Odgaard" throw-away-2@macromates.com wrote:
On 17 Apr 2008, at 02:52, Mark Eli Kalderon wrote:
Is there a way to modify the Open Terminal command so that it uses tabs with Terminal.app? I have been trying to do this but my applescript-fu is weak. :/
I see there is plenty of support for this in the scripting dictionary, but I also don¹t get AppleScript.
I tried first:
tell app "Terminal" to return tabs of first window
This worked fine, so then I tried:
tell app "Terminal" to make new tab in first window
That gave me:
Terminal got an error: Can¹t make or move that element into that
container. (-10024)
And then I gave up :)
Giving up is correct behavior! :))) The whole frustration with AppleScript is that you have no way of knowing whether a feature is implemented ("Is it possible to script the Terminal to make tabs in a window?") and, if so, what the syntax is for making it happen.
I believe the matter at hand (unless I've misunderstood - I haven't really been following along) has been pretty well discussed here:
http://onrails.org/articles/2007/11/28/scripting-the-leopard-terminal
m.
Is there a way to modify the Open Terminal command so that it uses tabs with Terminal.app? I have been trying to do this but my applescript-fu is weak. :/
I see there is plenty of support for this in the scripting dictionary, but I also don’t get AppleScript.
I tried first:
tell app "Terminal" to return tabs of first window
This worked fine, so then I tried:
tell app "Terminal" to make new tab in first window
That gave me:
Terminal got an error: Can’t make or move that element into that
container. (-10024)
And then I gave up :)
Giving up is correct behavior! :))) The whole frustration with AppleScript is that you have no way of knowing whether a feature is implemented ("Is it possible to script the Terminal to make tabs in a window?") and, if so, what the syntax is for making it happen.
I believe the matter at hand (unless I've misunderstood - I haven't really been following along) has been pretty well discussed here:
http://onrails.org/articles/2007/11/28/scripting-the-leopard-terminal
Haha. The author ends up recommending a variant of the same hack I settled for:
Tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
What a disappointment! And why does "make" fail here? Ah well...
Best, Mark
Haha. The author ends up recommending a variant of the same hack I settled for:
Tell application "System Events" to tell process "Terminal" to keystroke
"t" using command down
What a disappointment! And why does "make" fail here? Ah well...
I finally settled on a slightly different hack that I like better. Jacob Rus posted a couple of utility functions here: http://pastie.caboo.se/14358
Using those, my make_tab function looks like this: on make_tab(style) my menu_click({"Terminal", "Shell", "New Tab", style}) end make_tab
So the final script looks something like property tabStyle : "Pro" tell application "Terminal" activate make_tab(tabStyle) end tell
I archived the utility functions here in case the pastie goes away: http://geoff.mollyandgeoff.com/blog/2008/02/09/programmatically-create-new-t...
HTH,
Geoff
On 4/21/08 7:22 PM, in article 511E8F23-6D8A-4F6D-B898-C7EA42CC352A@markelikalderon.com, "Mark Eli Kalderon" eli@markelikalderon.com wrote:
Haha. The author ends up recommending a variant of the same hack I settled for:
Tell application "System Events" to tell process "Terminal" to
keystroke "t" using command down
What a disappointment! And why does "make" fail here? Ah well...
If this is important to you, please file a bug with Apple (against Terminal and the flaws with its scriptability). m.
On Mon, Apr 21, 2008 at 11:36 AM, Allan Odgaard throw-away-2@macromates.com wrote:
On 17 Apr 2008, at 02:52, Mark Eli Kalderon wrote:
Is there a way to modify the Open Terminal command so that it uses tabs
with Terminal.app? I have been trying to do this but my applescript-fu is weak. :/
I see there is plenty of support for this in the scripting dictionary, but I also don't get AppleScript.
I tried first:
tell app "Terminal" to return tabs of first window
This worked fine, so then I tried:
tell app "Terminal" to make new tab in first window
That gave me:
Terminal got an error: Can't make or move that element into that container. (-10024)
And then I gave up :)
I have honestly always been very surprised by the inconsistent scripting support among Apple apps.
That said, this works beautifully in iTerm: --- tell application "iTerm" activate tell the first terminal launch session "Default Session" end tell end tell
-Chris
On 2008-April-17 , at 02:52 , Mark Eli Kalderon wrote:
Is there a way to modify the Open Terminal command so that it uses tabs with Terminal.app? I have been trying to do this but my applescript-fu is weak. :/
I've Applescript code to open a Terminal window/tab depending wether current tab is busy (and wether some modifier keys are pushed but that should not interest you) there: http://jo.irisson.free.fr/?p=59 There are also modifications in the comments to improve it, which I haven't had time to integrate yet.
Hope that helps and indeed it is a shame that Apple did not make it easier to create new tabs.
JiHO --- http://jo.irisson.free.fr/