Auto open 4 terminal sessions and SSH them to a given host

sshterminal

I'm doing Rails development on a MacBook via a VirtualBox setup that's somewhat similar to Vagrant. My inconvenience is that I like to have at least 3 terminal tabs connected to the VM via SSH (one for running the Rails server, one for the Rails console and the third to run general command, possibly others for running tail, etc) and I have to open these connections every time I start developing.

Is there a way to automate this?

Best Answer

You could try creating a profile for each tab (changing Shell > Run command), opening tabs for each profile in some window, and then saving the window as a window group. See this answer.

Or use an AppleScript like this:

tell application "Terminal"
    activate
    do script "echo 1" -- this always opens a new window
    tell application "System Events"
        keystroke "t" using command down
    end tell
    do script "echo 2" in window 1
end tell

Other related questions: