2

I want to programmatically create one and only one Terminal.app window that's uniquely identified by a literal Terminal.app window title (let's call it 'MyConsole1') and send bash commands to said window for the life of the Terminal.app process.

Can this be done with Terminal.app, and if so, how?

Details

My program probably needs to check if 'MyConsole1' is already open before I go try to create a new one. And of course, start Terminal.app if it's not already running. I also want the commands issued to and over the life of 'MyConsole1' (by my program) to be bash-command-history retrievable by a human user; ie, the user can interact with 'MyConsole1' if desired. I'm not concerned about user-vs-program "conflicts" that might arise for use of the 'MyConsole1'.

I presume I need AppleScript to do this. I will be running the AppleScript as part of a much-larger Python application, possibly via a method like this, in case that matters.

I see how Terminal.app window/tab title(s) can be set like this, but this solution doesn't work for my requirements above. Further, I only want 1 tab in the window, and the title to apply to the entire window, and not just the tab.

Community
  • 1
  • 1
Johnny Utahh
  • 2,389
  • 3
  • 25
  • 41
  • What you're describing is fairly easy if you use iTerm instead of Apple's built-in Terminal.app. I gave up on trying to do more or less exactly this with Apple's Terminal.app and switched to iTerm. iTerm has much better support for Applescript. If you want to take a look at some code here is the project: http://dustractor.github.io/iTermBlenderLauncher/ – dusty Apr 04 '15 at 19:48

1 Answers1

0

I'm not sure if this is what you mean, but you can try this:

tell app "Terminal"
    activate
    do script ""
end tell