Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to spawn multiple Terminal windows UNIX
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...]
    •    
  • Currently 1.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[17,188 views]  

An AppleScript to spawn multiple Terminal windows | 7 comments | Create New Account
Click here to return to the 'An AppleScript to spawn multiple Terminal windows' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to spawn multiple Terminal windows
Authored by: wgscott on Jun 11, '07 08:19:44AM

You gotta try iTerm



[ Reply to This | # ]
An AppleScript to spawn multiple Terminal windows
Authored by: neuralstatic on Jun 11, '07 03:15:48PM

definitely..

iterm auto runs an applescript on launch. i have it open 6 servers with different colors in different tabs. plus it has a great options for regular use applescripting.



[ Reply to This | # ]
An AppleScript to spawn multiple Terminal windows
Authored by: Chuck Jonah on Jun 11, '07 08:55:38AM

Two comments -- one the cursor color is pretty difficult to see, (and impossible on green) I changed it to a grey {30000,30000,30000}.
Second, I tried to add a white to the list and the text ended up white also -- it appears as if the if cur color etc. equal sign does not work -- possibly a characteristic of applescript, but as I am not yet on my first applescript, I don't know



[ Reply to This | # ]
Alternate to: An AppleScript to spawn multiple Terminal windows
Authored by: snuff on Jun 11, '07 09:33:50AM

I too open multiple terminal windows daily to connect to different systems. What I've done is connect to the servers using "File -> Connect to Server...". Save each of the individual windows after assigning them their colors and size. I do this with a total of 9 windows with distinct colors for each type of server; eg. 5 mail relays white on blue, black on orange for a centralized logging system, black on yellow for local, green on black for an admin server, etc.

Once I have the saved connections for each I close them all, then open them in the order I want them numbered, position them on the screen where I want each, then do another file-save, this time choosing to save "All Windows" and naming the saved file as "-morning.term".

Now, when I launch terminal in the morning I just do a cmd-O and hit enter (the "-morning.term" is the first entry in my list). All my windows open, with the color I want, the right size, and the desired position. Also, because I opened them in the specific order I wanted before saving "-morning.term" I can now switch to them quickly using cmd-1, cmd-2, etc.

You could also...
-Save -morning.term to open automatically when you open terminal. (I don't since I'm on a laptop and not always on the right network.)
-If you're using SSH, setup to automatically login to the server.



[ Reply to This | # ]
An AppleScript to spawn multiple Terminal windows
Authored by: baba on Jun 11, '07 09:47:54AM
Have a look at the colowrap script. I use a variation of this. Very nice, since the the color doesn't change until I actually ssh to a given server, then reverts when I log out of that server. I used to just used saved terminal sessions, but that's much less flexible.
http://www.macosxhints.com/article.php?story=20050920183403172

[ Reply to This | # ]
An AppleScript to spawn multiple Terminal windows
Authored by: psifertex on Jun 11, '07 10:35:47AM

Why not use gnu screen? That's exactly what it's for, except it has the advantages that:

  1. It's easier to customize the startup of it via a .screenrc file
  2. It can be de-attached and re-attached even if you log out of the gui as long as the box is still up.
  3. It supports its own copy/paste buffer which is useful when working with bug chunks of text inside multiple machines.
  4. You can share the session and allow others to view what you're doing!

There's many other advantages as well. One thing to note -- by default, screen doesn't really give you much feedback as to which screen you're on, so adding something like the following to your .screenrc file is useful:

caption always "%{=}%?%{r}%H %L=%{+b}%?%{b}%-Lw%47L>%?%{w}%n*%f %t %?%{b}%+Lw%?%{g}%-31=%c %l %Y-%m-%d"

[ Reply to This | # ]
An AppleScript to spawn multiple Terminal windows
Authored by: useEvil on Jun 15, '07 06:28:52AM
Use 'screen' and only ever open one terminal window.

http://www.kuro5hin.org/story/2004/3/9/16838/14935

http://www.gnu.org/software/screen/

http://freshmeat.net/articles/view/581/

Make it colorful.

http://www-128.ibm.com/developerworks/linux/library/l-tip-prompt/

---
--
Fingerprint: 6196 6907 1E47 880A 76AA B6FD E9B6 A5D9 5D83 87BA
Public Key ID: 5D8387BA

[ Reply to This | # ]