Auto open 4 terminal sessions and SSH them to a given host 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?
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:


How can I write a script to open multiple terminal tabs and execute code in them?
How can I open multiple customized terminal shells?
Is it possible to script opening terminal with 3 tabs?
Trying to use applescript to launch cmd line 3 scripts in new tabs