O'Reilly logo

Learning Unix for Mac OS X, Second Edition by Dave Taylor, Brian Jepson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Customizing Your Session

One of the great pleasures of using Unix with Mac OS X surrounding it is that you get the benefit of a truly wonderful graphical application environment and the underlying power of the raw Unix interface. A match made in heaven!

This chapter discusses how to customize your Terminal environment both from the graphical user interface using Terminal Window Settings and from the Unix shell by using shell configuration files.

Launching Terminal

Launch Terminal and you have a dull, uninspiring white window with black text that says “Welcome to Darwin!” and a shell prompt. But that’s okay. We can fix it.

Tip

By default, Terminal uses tcsh as its shell. If you’d like to configure it to use a different shell, you can do so by selecting Terminal Preferences and specifying the shell to use.

Changing Terminal Preferences

To change the display preferences in the Terminal application, go to the Terminal menu and choose Window Settings.... You see a display similar to Figure 4-1.

Shell Settings

Figure 4-1. Shell Settings

At the top of the window, notice that a drop-down list lets you select which options to configure: Shell, Processes, Emulation, Buffer, Display, Color, and Window. The names suggest what each does, but let’s have a closer look anyway, particularly since some of these settings definitely should be changed in our view. It’s worth pointing out that these changes affect only the current window unless you click “Use Settings as Defaults,” after which they will apply to all future Terminal windows that you open.

Shell

When you first open Terminal Preferences, the Shell settings are displayed, as shown in Figure 4-1. On this panel you can specify that when a login shell exits, the Terminal application can close the window, close the window only if the shell exited cleanly (that is, returned a nonzero status code, which means that all the applications gracefully shut down), or never close the window. If you like to study what you’ve done and want to be forced to explicitly close the Terminal window, “Don’t close the window” is for you. Otherwise, either of the other two will work fine.

Processes

One of the more subtle capabilities of the Terminal application is that it can keep track of what applications you’re running so it can be smart about confirming window close requests: if there’s something still running in the window, it’ll pop up a dialog box asking if you’re sure you want to quit. This feature is very helpful if you are prone to accidentally clicking the wrong window element or pushing the wrong key sequence.

The Processes window shown in Figure 4-2 lists all the processes running under the Terminal window, and lets you specify what to do when you close a window. Set “Prompt before closing window” to Always if you’d like Terminal to always ask before closing the window or set it to Never to prevent it from ever asking. You can also use “If there are processes other than” setting (the default) to ignore the programs shown in the list (you can add or remove items from this list).

Processes

Figure 4-2. Processes

Emulation

These preferences, shown in Figure 4-3, don’t need to be altered by most users. If you’re using the Emacs text editor, however, you may want to select “Use option key as meta key.” What’s a meta-key sequence? Emacs uses lots of Control, Alt, Control-Alt, and similar key sequences for complex commands, and one modifier it uses is a new-to-Mac-users “meta” key. If you use Emacs, you’ll see when the meta key is necessary. If you don’t want to enable this option, you can use the Escape (Esc) key as the meta key for Emacs.

Emulation

Figure 4-3. Emulation

Tip

Some Titanium PowerBook G4s have a long delay before emitting audio, and if you’ve got one of these and you’ve noticed it as a problem, deselect “Audible bell” to neatly sidestep the problem. This also has the nice side effect of preventing people around you knowing when you’ve made a mistake.

Otherwise, it’s best to leave “Paste newlines as carriage returns” so that you can ignore the difference in end-of-line sequences in Mac files versus Unix files, and to avoid strict “VT-100” emulation, because it can get in the way of some of the newer Mac OS X Unix utilities. Whether or not you enable “Option click to position cursor” might depend on whether you’re a Unix purist (for whom the “good old keyboard” works fine) or whether you’re trying to simplify things. Beware that if you do enable Option-Click positioning, it won’t work in all cases, only when you’re in a full-screen application such as Emacs or vi.

Buffer

The settings in this area probably don’t need changing. The scrollback buffer allows you to scroll back and review earlier commands and command output. The default value of 10,000 lines should be more than enough for most people. If you want to use less memory, you can put in a smaller number or completely disable the scrollback buffer, rather than specifying a size.

You can also choose whether the Terminal should wrap long lines (not all Unix programs will wrap long lines, and so they might disappear off the edge of the window if this option isn’t set), or whether you should automatically jump to the bottom of the scroll buffer upon input, if you’ve scrolled back to examine something that transpired earlier in your session. These options are set by default, and you should probably leave them that way.

Display

One area that you’ll probably fine tune more than others is Display. Here you can specify a different (or larger) font, define the shape of your cursor within the Terminal window, and control character set encoding.

While you can choose any font available on your system, you’ll find that your display is much more comprehensible if you stick to monospace or fixed-width type. Monaco is a very good choice, and is the default typeface for the Terminal application.

Finally, you can specify a nonstandard string encoding if you’re working with an unusual language or font. The default UTF-8 (Unicode 8-bit) encoding will work in most situations.

Color

The Color settings let you change the normal text, background, bold text, cursor, and selection colors, as well set the transparency of your Terminal window. The default color settings display black text on a white background, but we find that light text on a dark background is easier to read for extended periods. One suggested setting is to have the background very dark blue, the cursor yellow, normal text light yellow, bold text light green, and the selection dark green.

Window

If you have a large display, or are running at a higher resolution than 800x600, you’ll find it quite helpful to enlarge the Terminal window to offer a bigger space within which to work. The default is 80 characters wide by 24 lines tall, as shown in Figure 4-4.

Terminal Inspector window

Figure 4-4. Terminal Inspector window

The title of each Terminal window can be fine tuned too: you might find the device name (what you’d get if you typed tty at the shell prompt) and the window dimensions particularly helpful.

Tip

If you want to change the Terminal window title at any point, you can use the Set Title option by either choosing it from the File menu or typing

Terminal Inspector window

-Shift-T.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required