0

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?

2

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:

  • I'll have a look at the resources you mentioned. I'll probably figure something out. Thank you. – janosrusiczki May 5 '13 at 16:22
1

This Applescript should work for you, just replace the values on the first two lines to your liking. It opens a new window with the number of tabs specified (on line 2), and runs a given command in each of them (set on line 1).

Use AppleScript Editor or Automator to turn it into an application you can run like any other app, or you can use something like FastScripts or Keyboard Maestro to run it from a hotkey.

set mycommand to "echo test"
set number_of_tabs to 3

tell application "Terminal"
    activate
    -- open new window
    tell application "System Events"
        keystroke "n" using command down
    end tell
    do script mycommand in front window
    repeat number_of_tabs - 1 times
        my create_tab()
        do script mycommand in front window
    end repeat
end tell

on create_tab()
    tell application "System Events"
        keystroke "t" using command down
    end tell
end create_tab

You must log in to answer this question.

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