Terminal Application and Alternatives

From OS X Scientific Computing

Jump to: navigation, search


The Terminal Application and Alternatives

OS X includes an application, Terminal.app, that provides unfettered command-line access to the entire unix underpinnings of the operating system. The Terminal application (the .app suffix on all applications is hidden from view in the GUI) may be found in the directory /Applications/Utilities. Its icon looks like (surprise) a terminal. In addition to the Terminal application that Apple provides with OS X, other options are available. iTerm.app is a free, third-party application that is similar to Terminal.app but has additional functionality, most notably tabbed windows. Similarly, xterm is provided with Apple's X11.app (see section [#xwindows_section 1.2]), and any other x-windows-based terminal program may also be installed, so a user who requires all the familiar functionality of xterm or its brethren need not compromise.

Apple's Terminal.app

Apple's Terminal.app is provided in the default installation of OS X and can be found reliably in /Applications/Utilities and is invoked by double-clicking on the application's icon. For convenience, the Terminal application should be dragged into the Dock in the usual manner for easy access. Its functionality is similar (but not identical) to that of the xterm one finds on most other unix operating systems. The Terminal supports tabbed viewing as of OS X 10.5. When the application starts, it automatically starts a new unix shell. The shell is bash by default in OS X versions 10.3, 10.4 and 10.5; users who have upgraded from 10.2 or earlier may inherit tcsh as their default user shell. This is described in section [#unix_shells 1.5].

If you need to launch an X-windows based unix program from the unix command line in Terminal.app, you first need to set the DISPLAY environment variable. (Update: Do NOT set the DISPLAY variable in 10.5 Leopard) Briefly, this requires a command such as export DISPLAY=:0.0 to be issued either from a shell startup file or manually on the command line. (The previous command must be replaced with the command setenv DISPLAY :0.0 for tcsh users.) This is described in more detail in section [#unix_shells 1.5]. Launching an X-windows based unix program successfully will also require you to first install X11.app, as described in section [#xwindows_section 1.2].

As with other OS X applications, the behavior and properties of Terminal.app are controlled by changing the application Preferences, as well as Window Settings, from the main menu bar. The color of the text, background, window transparency, size and so on may be tailored to an individual's taste. This differs from the standard unix way of controlling an xterm's behavior via command-line arguments or rc file, but is arguably easier to do. (One of the most truly delightful characteristics of a well-written OS X application is that you don't have to read the instructions.)


iTerm.app is rather similar to Terminal.app in most respects. Like Terminal.app, one needs to set the DISPLAY environment variable in order to launch X-windows based programs from the command line. The main difference is that iTerm.app possesses additional functionality. A user can have several simultaneous terminal sessions in a single window. Each session has a corresponding tab, allowing the user to quickly change from one session to another in a manner very similar to tabbed web browsing in Safari.


Other enhancements include the ability to copy text into Apple's pasteboard buffer simply by highlighting it in the manner familiar to xterm users, the ability to paste text from the pasteboard by clicking the middle-mouse button (often emulated by the scroll-wheel on a three-button mouse[footnode.html#foot549 1.6]), and so on. It is also very easy to create multiple ``Bookmarks'' in iTerm, each of which may be programmed to generate a unique session. For example, I have created several bookmarks, each of which, when activated, automatically connects me to a specified remote computer account. Each bookmark can be assigned a unique ``Shortcut key'' combination, permitting the user to depress control-command-key to initiate the specified bookmarked session. An example is shown in Figure [#iterm_bookmark 1.1]. A unique color scheme has been chosen for the iTerm session that connects to the remote computer to help minimize confusion.


Figure 1.1: A screenshot depicting a programmed iTerm bookmark that corresponds to issuing the command ssh -X wgscott@xaxaxa.foobar.org. The L-key was chosen as the ``Shortcut key,'' enabling a new tabbed window to be opened by simply depressing control-command-L in which a connection to the remote computer is then established.

The iTerm Title and Tabs can be customized easily. I have described in detail how to do this for each of the commonly-used unix shells available with OS X in a document called iTerm tab customizations.

xterm, rxvt and friends

When Apple's X11.app (or equivalent) is installed, as described in section [#xwindows_section 1.2], the unix program xterm will also be installed in /usr/X11R6/bin, the canonical location for unix X11 system executables. It behaves just like xterm on any other unix platform. Other third-party xterm-like terminal programs, such as rxvt, aterm, and so on, can also be installed. Their main disadvantage compared to Terminal.app and iTerm.app is that they are not true native OS X Aqua applications; this is largely a matter of aesthetics. They do, however, tend to be faster, and they do not require the DISPLAY environment variable to be set explicitly. Their other advantage is that they behave the same way in OS X as they do on any other unix platform on which they are available.

Personal tools