Call me anal if you wish, but I like to have a grid of 4 Terminal windows always open, and typically I do specific things in each window so that when I want to go do that specifc thing, I just Cmd-Tab to Terminal, and Cmd-[1-4] to get to the window I want.

Normally, at work I have my laptop hooked up to an external monitor, and at home I use just the laptop screen (usually from the couch ;). Unfortunately, OS X (or Terminal) seems to have a bug in remembering window positions when a laptop switches in/out of suspend with the display layout changing (i.e. the external monitor attaches or detaches while in suspend). If you do this, you'll notice that the Terminal windows act a little wonky until you move them with your mouse (cicking in window may not activate it, scroll wheel may not work, scroll bar may not work, etc).

Needless to say, this annoyed the crap out of me, so much so that I even resorted to learning some applescript to work around the issue (maybe I'm too much of a normal coder, but applescript seems like such an ass backwards language).

Here is the script, note that I like my Cmd-[1-4] to map to a window which always has the same position on the screen (Cmd-1 always goes top left, Cmd-4 bottom right). I keep the script in ~/Library/Scripts/Applications/Terminal so that I can run it from the Script Menu in the menubar (Run the AppleScript Utility to turn on the Script Menu).


-- position grid of 4 windows to the following coords.
-- If you want a different layout, you'll have to mess with the code
-- Cmd-1: {187, 22} Cmd-2: {691, 22}
-- Cmd-3: {187,387} Cmd-4: {691, 387}
tell application "Terminal"
activate
set ymul to 0
repeat with winIdx from 1 to 4
tell application "System Events" to keystroke "" & winIdx using command down
set mywin to window 1
set oldpos to position of mywin
set xmul to 1 - winIdx mod 2
set newpos to {187 + (xmul * 504), 22 + (ymul * 365)}
set position of mywin to newpos
set ymul to ymul + 1 - winIdx mod 2
end repeat
end tell