Make new window/tab in Terminal without GUI scripting

Is there any way to achieve this?

I checked the dictionary and it lists make and tab and window.

I can also get info from tabs (app > window > tab) but still cannot make new objects with make new window.

Any suggestions? Btw, I use Terminal 2.3.

Operating System: Mac OS X (10.8.5)

Hello.

I think there should be a way to do what you want to do in a “clean” way, however, time is sparse today, and this works for me. :slight_smile:

tell application "Terminal" to activate
tell application id "sevs" to tell application process "Terminal" to keystroke "n" using command down

Hi.

It does seem odd that ‘make new window’, ‘make new window at front of windows’, or other variants don’t work. :confused:

This cheat works on my machine. I don’t think its preference-dependent:


tell application "Terminal"
	do script ""
end tell

Hello.

NIgel posted it, before I managed to post my finding. :slight_smile:

Yeah I knew that workaround, but since I use TotalTerminal, in the end I have to merge all new windows, and for merge there’s no applescript command, so again I would have to resort to GUI scripting.

Btw, does anyone know how to debug why a command is not working as expected?

Hello.

I’m not sure if I know what you mean, but there is a document at developer.apple.com, named “Debugging Magic”, it shows you how to raise/lower the message level of an app, so you can get a clearer view in console as to what is going on. There are also some variables that can be set in terminal, so that output is logged into Console.app, when you run a script through the osascript command. :slight_smile:

Hey McUsrII

Thanks for the hint. I’m not sure that’d enable ASE to show more granularity, for example, when executing

tell application "Terminal"
	make new window
		--> error number -10000
Result:
error "Terminal got an error: AppleEvent handler failed." number -10000

Hello.

No, maybe not in that end, as to the detail level in the error messages. however, notching up the error level, as to when you have no clues as to why something fail, for instance without an error message, or maybe an error that states that an apple event timed out, it can prove useful to inspect any internal error messages.

I won’t speculate as to if it is a bug, or not, that you can’t make a new window with the make new window command, but I think we all can agree that the dictionary of Terminal lacks a comment for the make command, that states how new windows are intended to be made.

I wonder if document is missing (I usually make new windows in Safari using that) or what purpose make serves in Terminal :confused:

Hello.

You make a new Finder Window for instance, and Finder windows aren’t based on documents either, so it hasn’t anything to do with the lack of the NSDocument class in the background of the window really.

tell application "Finder"
	make new Finder window
end tell

If you look in Terminal’s scripting dictionary, you’ll see that for window it says it responds to close, print, save – no mention of make. Dictionaries can lie, and there’s no obligation to list what commands a class responds to – most don’t for window, for example. But when they do, it can be a hint that they’ve implemented it a bit differently. And the absence of make in that list might well suggest it’s not accidental.

Speculation upon speculation…