[MacRuby-devel] Scripting Terminal.app with ScriptingBridge

Eric Christopherson echristopherson at gmail.com
Fri Jun 3 10:10:51 PDT 2011


On Thu, Jun 2, 2011 at 8:43 PM, Scott Thompson <easco at mac.com> wrote:
>>
>> I'm playing around with Scripting Bridge trying to script
>> Terminal.app. I'm running into issues with adding a new tab to a
>> window, and was hoping someone could point me in the right direction.
>> Consider this gist: https://gist.github.com/1005066
>>
>> The only information I could find that was remotely similar was doing
>> something similar with Safari here:
>> http://stackoverflow.com/questions/2912161/new-tab-in-safari-window-from-cocoa-and-scripting-bridge
>> I tried converting that over to MacRuby, and I get the same error as
>> when I try my gist above.
>>
>> RuntimeError: NSInvalidArgumentException: *** -[SBElementArray
>> addObject:]: can't add an object that already exists.
>>
>> Hopefully I'm just doing something silly?
>
> From what I've been able to find on the Web, the terminal app doesn't allow you to create a new tab using AppleScript (directly).  Instead what you have to do is address the System Events application and use it to issue a "cmd-T" command.

For an example of scripting Terminal this way, see Terminitor
<https://github.com/achiu/terminitor>.

>
> I would also report a bug against Terminal.app on bugreport.apple.com.
>
> Scott


More information about the MacRuby-devel mailing list