An AppleScript to spawn multiple Terminal windows

Jun 11, '07 07:30:00AM

Contributed by: axlotl

The first thing I do when I start to work is launch a slew of Terminal windows to log into various servers and/or interact with repositories and local files. I quickly found that is was helpful to color code them so, for instance, if I want to grab the one logged into server X, I can see them in Exposé and be able to choose the window I want by remembering its background color -- even without being able to read the characters. So I wrote a little AppleScript to automate the process; it can likely be improved as it's the first AppleScript I've written:

set RGBGreen to {0, 10000, 0} as RGB color
set RGBRed to {10000, 0, 0} as RGB color
set RGBBlue to {0, 0, 10000} as RGB color
set RGBBlack to {0, 0, 0} as RGB color
set RGBWhite to {65535, 65535, 65535} as RGB color

set RGBcolors to {RGBGreen, RGBRed, RGBBlue, RGBBlack}

repeat with curColor in RGBcolors
  tell application "Terminal"
    activate
    with timeout of 1800 seconds
      do script with command "pwd"
      tell window 1
        set background color to curColor
        set cursor color to RGBGreen
        if curColor = {65535, 65535, 65535} then
          set normal text color to RGBGreen
        else
          set normal text color to RGBWhite
        end if
        set bold text color to "red"
        set title displays shell path to true
        set title displays window size to true
        set title displays device name to true
        set title displays file name to true
        set number of columns to 120
        set number of rows to 40
      end tell
    end timeout
  end tell
end repeat

Obviously colors, the number of windows and the like are easily tweakable.

[robg adds: I haven't tested this one...]

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070604100629346