Cloning Terminal to Ease Window Management
Pages: 1, 2
Window Titles
It's easy to change the "Title" information that is used on each window. Pull down Terminal > Window Setting from the Menu Bar, then select the "Window" category. Change the "Title" fill-in to "TS2" (Terminal Set 2). Note that each copy of the app has its own preferences, window settings, etc. So, if you want to make a global change, you'll have to adjust each copy.
Menu Bar
If you have Xcode installed, you can change the Menu Bar to read "Terminal_2" (or whatever). Navigate to the Contents/Resources/English.lproj folder and double-click on Terminal.nib. After Interface Builder has started up, double-click on the "Terminal" string in "Terminal.nib (English) - MainMenu" and fill in the desired value (e.g., Terminal_2). Save and Quit.
Now, double-click on InfoPlist.strings. When a text editor window appears, change the value of CFBundleName to the same text string. Save and Quit. The next time you start up Terminal_2, the Menu Bar will read correctly.
Shell Support
It's handy for shell scripts to be able to find out which terminal set they're in. It's useful, for example, in dynamically setting window titles or command-line prompts. My current solution, which is a bit scary, is to edit the executable binary for the application. If you're comfortable with this idea, read on...
This hack is based on the fact that Terminal sets up a pair of environment variables for its sessions. One of these, TERM_PROGRAM, is normally set to Apple_Terminal. By editing Terminal's executable, we can change this value to a different text string.
Navigate to the Contents/MacOS folder. Using a binary-capable text editor (e.g., BBEdit), open the original executable. Search for the text string Apple_Terminal. In my executable, it is preceded by TERM_PROGRAM and followed by the string TERM_PROGRAM_VERSION, but Your Mileage May Vary.
Select the part of the string you wish to change and replace it with an equal number of characters. (I use Apple_Term_TS2 for Terminal_2.) Save and Quit. The next time you start up the app, this string will be available in TERM_PROGRAM.
If you're comfortable with scripting languages such as Perl, you might enjoy writing a special-purpose script to edit the file. I hacked together a script that edits TERM_PROGRAM, based on the name of the app in which the executable resides.
Final Thoughts
After a week or so of intensive use, this hack seems to be "wearing well." No crashes (or even glitches), and it provides the desired flexibility without adding more confusion to my life.
I would caution against setting up too many terminal sets, however, lest you get confused about what lives where. I currently have four terminal sets configured:
- TS1 - administrivia and miscellanea
- TS2 - my "work" project
- TS3 - my "hobby" project
- TS4 - unassigned, as yet
Although this exercise uses Terminal as its target app, the same sorts of changes could be made to any app. By (a) breaking up apps into phalanxes of files, and (b) giving us the tools to edit these files, Apple has given its users quite a bit of freedom. Not as much as an Open Source application would provide, to be sure, but still very handy on occasion.
Although he bears no blame for any of my ideas or mistakes, David Hill was splendidly helpful in my effort to change the app's title in the Menu Bar. Having worked closely with David in co-authoring the Mac OS X Technology Guide to Spotlight for SpiderWorks, I expected no less. Nonetheless, it's nice to have one's positive expectations confirmed.
Rich Morin are long-time users of both Mac OS and Unix. For obvious reasons, they find Mac OS X to be totally delightful.
Return to the Mac DevCenter
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 8 of 8.
-
another vote for iTerm
2006-06-05 09:57:02 kwidholm [Reply | View]
Can't live without it. Tabs can be named automatically, can be switched between with customized keystrokes, and the tabs will change color upon activity. 10 terminal sessions at once, all at my fingertips, in one window.
-
ever try Space.app?
2006-06-03 09:32:52 Mr_Dave [Reply | View]
I've used an app calles Space. It gives me multiple desktops so I can keep different functions seperated. I wonder if this would work for what you do.
-
iTerm
2006-06-02 01:29:35 Dr.Michael [Reply | View]
A very convenient way to avoid fiddling around with screen, is iTerm. I completely stopped using screen or terminal on my macs since I have found this simple little app. It just opens terminals in one window and gives access to them via tabs. Problem solved!
-
Term files and File > Library
2006-06-01 17:52:50 chopblock [Reply | View]
I use a number of term files located in ~/Library/Application Support/Terminal/ each with different colors, commands, and screen locations to manage windows. The nice part is that in System Prefs > Keyboard you can set keyboard shortcuts to open these term files. This is useful because i can remember that my green window the upper left corner is mysql on server x, while the red one below it is local etc. not a sophisticated as this setup, but someone may find it useful.
-
An easier way
2006-06-01 16:59:35 thewayofthegun [Reply | View]
That's all amusing but rather silly.
If anybody is using the command line enough that this hack is worthwhile, they are better off running GNU Screen, which comes installed on every Mac. GNU Screen presents a bit of a learning hurdle at first, but once you are off and running, you will wonder how you ever got along without it. -
An easier way
2006-06-01 19:37:00 Andy Lester |
[Reply | View]
Screen also doesn't help as far as having scrollback available to the Mac's desktop. I often will copy entire scrollback buffers and paste them in another application. -
An easier way
2006-06-01 17:35:33 rdm [Reply | View]
screen(1) is a convenient and powerful tool. Originally written to allow character-oriented display terminals to emulate windowing capability, it can also be used within Terminal windows. Its ability to detach from and re-attach to program sessions is particularly cool.
However, it does little for the user who wants to manage a number of Terminal windows, viewing them simultaneously and moving them on and off the screen(s) as a set. This article (and the hack it describes) addresses that case.






into a shell will invoke another copy of Terminal. I haven't found out how to give it a different name, though.