At work I'm overseeing several users who use MacBooks to connect to our enterprise environment.

One of our vendors has an old server which users access via ssh. I've created an Automator workflow to launch terminal, set it up the way they like (legacy color scheme and font) and get them to the ssh prompt from the server. I get some unexpected behavior in that when the Automator workflow runs, it opens two Terminal windows, then window I want (ssh client) and then another regular Terminal login.

If the ssh window is closed, Terminal remains open, and the next time the workflow is run, the window isn't visible until the user manually switches to Terminal.

The other peculiarities I'm observing seem to be tied to the fact that the AppleScript spawns two Terminal windows, and then the users simply closing the window rather than quitting Terminal when exiting. Is there a better way to do this? Could I have Terminal quit by default when the "Close Window" button is hit?

Caveats: This is a controlled environment. I'm pushing my luck with vendor support using Terminal already, they didn't want to support anything other than Linux ssh. 3rd party applications are not acceptable solutions.

  • Why not issue killall terminal before spawning the next session? see apple.stackexchange.com/a/223048/5472 for all the kills :-)
    – bmike
    Commented Jan 11, 2016 at 18:13
  • @bmike, that's a good idea - here's hoping none of the users are doing anything else in Terminal (HA!) Commented Jan 13, 2016 at 21:50
  • You could warn them with a dialog or just publish a web page that's with the names/times/phone numbers of users as they check out licenses. I've had good success with that. Let the person needing the license pester the person who didn't clean up after their work. :-)
    – bmike
    Commented Jan 13, 2016 at 22:45

1 Answer 1


You can force Terminal to become frontmost by adding the line:

activate application "Terminal"

into your applescript.

if you launch Terminal with:

tell application "Terminal" to open location "ssh://[email protected]"

then Terminal won't open an extra window.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .