![](/file/12652/www.mactech.com.tar/www.mactech.com/sites/all/themes/custom_front/images/you_are_here_red.gif)
![](/file/12652/www.mactech.com.tar/www.mactech.com/sites/default/files/beta-site.gif)
|
Volume Number: 23 (2007)
Issue Number: 11
Column Tag: Mac in the Shell
Leopard Terminal.app: Create Your Workspace
Have all the comforts of ~
by Edward Marczak
Introduction
Of all the new features that Leopard brings, one might not think that there could be excitement about Terminal.app. One would be wrong. Along with many others, Terminal.app is my primary interface to the system. Yes, I use applications like Word and Mail.app, of course, but the bulk of the time, I'm looking at a green blinking cursor on a semi-transparent black background. I know I don't have to extol the virtues of shell-mastery any more - you've read that enough in this column. However, OS X 10.5, "Leopard," updates Terminal.app in some nice ways. Let's look at the changes, and then ways to customize your workspace so you're making your environment work for you, not against you.
In the Beginning was the Command Line
Perhaps the easiest thing to point out is that Terminal.app has a new icon. It's amazing how jazzed we can all get over an application's icon, but that's just part of the Mac way, I suppose.
![](/file/12652/www.mactech.com.tar/www.mactech.com/articles/mactech/Vol.23/23.11/2311MacInTheShell/fig1.jpg)
Figure 1 - New Terminal.app icon
It works nicely with the other interface changes in Leopard: a little flatter, but much more stylized.
If you've performed a clean install - which, by the way, I'm a huge advocate of for major releases - and you're not using previous preference files, launch Terminal.app from the Utilities folder and you'll see a default terminal.
![](/file/12652/www.mactech.com.tar/www.mactech.com/articles/mactech/Vol.23/23.11/2311MacInTheShell/fig2.jpg)
Figure 2 - a console window in its default state.
Well, OK...a little bland, perhaps. Nor will 80x25 cut it in most cases. So, let's start with the easy stuff. Stretch that window out and position it on-screen where it best suits you. I like virtual pagers, like Spaces and VirtueDesktops, so, I highly recommend that Terminal gets its own screen. You may also want multiple terminals open at once, and I'll touch on that a bit more later, but suffice it to say, I basically never have less than 9 VTs open at once on my local machine.
Also easy: if you're familiar with Terminal.app already, you won't be lost. Some of the prefs take a minute to absorb, and some items have simply been renamed (gone is "Connect to Server..." replaced with "New Remote Connection...").
A cry for sanity in our silent night of madness
One Mac In The Shell column that has generated a good deal of feedback had screen as its topic. One of Terminal.app's new features happens to be tabs, and most people would think that would do away with screen. Not a chance.
If you're in love with tabs, you probably have been using iTerm or Terminator to satiate your needs. Basically, tabbed terminals have existed for OS X, so, this is catch up for Terminal.app. It's a nice addition nonetheless.
Now, I was the first one that thought I'd just ignore tabs in Terminal.app. I already use screen, right? Turns out, I find them both useful. (If you need a refresher on screen, check out my original article which now appears on-line at http://www.mactech.com/articles/mactech/Vol.21/21.09/Screen/index.html).
Creating a new tab is as simple as Apple-t, which gives you a new tab in the current window with the default scheme. Or, mouse about to the Shell menu, choose "New Tab", and choose the scheme you'd like. Thankfully, we can change tabs with the same key commands available for tabs in Safari - Apple-Shift-} and Apple-Shift-{. (This goes for tabs in iChat, now, too). So, if your muscle memory is built up like mine, this is a nice addition.
Once any window - tabbed or not - is created, pull up the window inspector using Apple-I, or Shell->Show Inspector to change the properties of an existing window (more detail on Inspector later). See Figure 3 for a look at the Inspector itself, with its settings tab open.
I have screen give me 7 VTs at terminal start, and now, one terminal window gives me a two tabs. Why stick with screen? First, screen is less resource hungry than Terminal.app's tabs. Allocating a new bash shell under screen just pops up my memory usage by 800k or so. Each Terminal.app tab takes up about 1.5MB. Why the heck am I concerned about this in the age of multi-Gigabyte machines? Well, perhaps, that's just what I do. Plus, despite the 4GB of RAM that my machine has, it still gets strained while running other apps, virtualization and yes, Warcraft (I can quit anytime. Really). So, that memory counts!
Also, when shelling into a remote machine, I typically still have screen at my disposal, and can just fire up a remote screen session. It seems a bit wasteful to open up many local tabs and ssh each one of those to the same remote host. Finally, screen is just wired into my fingers, so, I stick with it for that and its other nice tricks (and I get to take my .screenrc file to my new home directory and have everything work as expected - what could be better?).
![](/file/12652/www.mactech.com.tar/www.mactech.com/articles/mactech/Vol.23/23.11/2311MacInTheShell/fig3.jpg)
Figure 3 - Terminal tabs and the Inspector window floating over.
the color of television, tuned to a dead channel
Everyone has their own idea of what a perfect terminal screen should look like. Me? I like the 'classic' look of green (or even amber) on black. That's just the way it was. But I also have a 'classic' Commodore 64 looking terminal (blue on blue). While this may seem trivial at first, you're going to be staring at these screens a lot. Also, you're going to need to pick out text from the rest of the clutter on screen. So, find a color scheme that you like and a font that suits you. This has been made easier with the current incarnation of Terminal.app.
![](/file/12652/www.mactech.com.tar/www.mactech.com/articles/mactech/Vol.23/23.11/2311MacInTheShell/fig4.jpg)
Figure 4 - Preferences and Color Picker
While slightly confusing at first, the new preferences really are simplified. Gone are the separate "Preferences" and "Window Settings" menu choices. Now, all 'preferences' are consolidated. Colors, fonts, window sizes and more can be found under the "Settings" group. You can easily define groups of styles that you like and save them for future use, and even export the settings for your or other's use.
One exceptionally nice touch is that if you have a saved terminal definition from, oh, you know, the Tiger days, just double-click it. Not only will you be looking at your familiar terminal, but Terminal.app 2 will import the setting, making it easily called up in the future. To this I say, thankyouverymuch!
Additionally, if you like to have multiple terminal windows open at the same time, the new Window Groups feature is a blessing. All you have to do is get your terminals arranged as you like them: color, fonts, size and position. Then, that can be saved as a Window Group. Simply use the "Save as Window Group..." menu item from the Window menu, or, add it with the "+" button in the Window Group section in Preferences.
![](/file/12652/www.mactech.com.tar/www.mactech.com/articles/mactech/Vol.23/23.11/2311MacInTheShell/fig5.jpg)
Figure 5 - Saved Window Groups
Finally, you can choose a Window Group to appear when you launch Terminal.app. What a fantastic feature!
As far as all of the other Terminal.app accoutrements that you've gotten accustomed to, they're all still there. For anyone in love with Transparency, take note where the opacity slider has moved to. Interestingly, this lets you set opacity on any color element, including text and your highlight color. In other words, you can either end up with something very cool looking, or something that impossible to read!
It is by will alone I set my mind in motion
What else has changed? There is one topic I haven't covered before in this column that I've had some people ask me about recently. Back in the day, when we would be talking about physical terminals, the host system had to know the terminal's capabilities. The terminal that you were using possibly had a real, hardware limit on how many columns it could display, if it supported color or blinking text, graphic support, etc. Ultimately, each terminal's capabilities got catalogued and placed into the termcap database. Fast forward to a contemporary setup, and termcap has become terminfo. Same idea, different name. Figure 6 shows where in Preferences->Settings we declare which terminal type we're emulating (what we're pretending to be).
![](/file/12652/www.mactech.com.tar/www.mactech.com/articles/mactech/Vol.23/23.11/2311MacInTheShell/fig6.jpg)
Figure 6 - Declaring our terminal type
Interestingly, if we're running screen - I use it as my shell - we get a terminal type of screen. There also happens to be a terminfo entry for screen, declaring the capabilities your terminal will have.
Ever notice how after looking at a man page, or say, after using vi, you get the contents of your terminal back. Just like you had never run man or vi? Other programs will do this for you, too. Some physical terminals had an alternate screen buffer that apps are directed to, and when they quit, the main buffer is swapped back in. The xterm-color terminal in OS X mimics that. So, you're poking around the filesystem using cd and ls nad find a text file that you need to edit. Your terminal window is littered with browsing history and the prompt is at the bottom of the window. You fire up vi, edit the file, save and quit. Lo and behold, you're back where you were before editing. The scrollback buffer shows no evidence of the vi session.
screen, coincidentally, has its own scrollback buffer that overrides terminal's. So, as items scroll past the top of the window, they seem gone. Using screen's scrollback (ctrl-[ by default), you can go back through terminal output. Personally, I like my two-finger scroll, despite the mish-mash you get in the process. Apparently, many others do, to, as the first question I get from people that I turn-on to screen is, "why can't I use the scroll bar anymore?"
This is an easy one with a nice fix - "nice" meaning that you can alter the behavior for you, not touch the system defaults, and furthermore carry the change around with you in your home directory. screen lets you override the terminfo entry for a given terminal. Simply place the following line in your .screenrc file:
termcapinfo xterm* ti@:te@
Bail out of screen if it's already running and fire it up again. Use top. Go ahead. Now quit top. All of that output stays plastered all over your terminal. Beautiful, beautiful output! That line simply tells any xterm running under screen that it no longer has the capability of an alternate buffer. It basically redefines the escape codes. If more of this type of skullduggery intrigues you, start with the term(5) man page.
There's a frood who really knows where his towel is
Terminal 2 really brings some nice touches and conveniences to those of us who use a command shell as their primary interface to the system. Even if you don't use it as often as others, getting deep into the system as a developer or sysadmin means breaking out Terminal.app on more than a passing occasion. By this point, you should have a productive and attractive (to you) workspace that works with you.
Media of the month: I should probably be recommending something Leopardish. I can't just yet. But, I was in a book store (again) just the other day and realized how long it had been since I sat down and read fiction. Made up characters, made up places and made up tales. You need to be in touch with reality, but exercising creativity also ranks pretty high. If you've never ready anything by William Gibson, that's my recommendation. Find one that you like. If you've never read anything by Neil Gaiman, please, hurry to your local bookshop and pick up "American Gods" or "Neverwhere." And if you've never put eyes to paper that contains "The Hitchhiker's Guide To the Galaxy," then, run! Go now!
We're also getting close to Macworld. So close that if you haven't made your plans yet, you may be too late. Fire up your web browser, purchase tickets, your travel and hotel for this worthwhile event. Hope to see you there!
Ed Marczak is just this guy, you know? Find out why at http://www.radiotope.com
![](/file/12652/www.mactech.com.tar/www.mactech.com/sites/all/themes/custom_front/img/search_text.gif)
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine