I work on a Mac with Lion (10.7.5). I want to create a clickable desktop shortcut that will open the terminal app with multiple tabs where each tab is an ssh session to a remote machine. What is the best way to do this?


Open your SSH connections using Shell » New Remote Connection (just type ssh user@hostname into the text field at the bottom, no need to set up a configuration). They'll each open in a new window, but you can merge them e.g. using Window » Merge All Windows.

Once you're happy with your setup, select Window » Save Windows As Group and check Restore all commands.

Restart Terminal. Select Window » Open Window Group », then select the window group you just saved.

Now we need a way to open this window group.

Alternative A: Export window group

Go to Terminal » Preferences… » Window Groups, select the window group you created, and select Export… in the gear menu. Save to the desktop.

You can now double-click the window group configuration on the desktop to open it.

Note that this actually imports it, creating a duplicate window group every time you "open" it.

Alternative B: UI Automation

To automate opening the window group, we'll use UI scripting, as there's no other API to control this part of Terminal. Open AppleScript Editor, and paste the following:

tell application "System Events"
    tell application process "Terminal"
            click menu item "foo" of first menu of menu item "Open Window Group" of menu of menu bar item "Window" of first menu bar
        end try
    end tell
end tell
tell application "Terminal" to activate

Replace foo with the name you assigned your window group.

Optionally click Run to test this in AppleScript Editor. You might need to change your Assistive Apps security configuration in System Preferences for this.

If it works as desired, select File » Save As… in AppleScript Editor and save to your desktop as application. Quit AppleScript Editor and double-click the script application you just created. You'll need to change your Security preferences once again, and from then on it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.