CNET también está disponible en español.

Ir a español

Don't show this again

Christmas Gift Guide

Tips for the Terminal in OS X

If you use the Terminal regularly, because it is basically a window under the hood of OS X you may find yourself focused on the active shell and overlooking a number of the features the Terminal application itself offers.

The Terminal is a widely used application for getting to the OS X underpinnings, and we frequently recommend using it to tackle small problems in OS X. If you are a regular Terminal user, because it is basically a window under the hood of OS X you may find yourself focused on the active shell and overlooking a number of features the Terminal application itself has to offer.

Pasting "Escaped" Text

When coding, special characters like quotes, brackets, and other symbols may be interpreted as code. If you are copying and pasting large bodies text into code in the terminal that you wish to keep intact and not have characters interpreted as code, you will have to escape symbol characters using a backslash before them. This can be mundane work, so the Terminal has a feature to paste text and introduce backslashes before commonly "escaped" characters. To do this, copy your text as usual, and press control-command-V (or select "Paste Escaped Text" from the Edit menu) to paste it into the terminal.

Escaped text can be useful when pasting bodies of text into code.

Exporting text

Periodically you may wish to save the output of commands as seen in the Terminal window. This can be done several ways, some of which may be more convenient than others for various tasks.

  1. Redirecting output

    A commonly used Unix trick is to redirect the output of a command to a file. Using the greater-than symbol (>) you can save the output of any command to a file. For instance, to save the listing of a directory to a file in the user's home directory (designated by the "~/" symbols), one would enter the following command:

    ls > ~/folder_contents.txt

  2. Directly copy

    Use the mouse to select the contents of the Terminal window that you wish to save, and then copy it to a TextEdit or other editor's window. You can also drag highlighted text to a Finder folder where it will be saved as a text clipping that can be inserted into a number of applications.

  3. Use the "Export Text" option

    In the "Shell" menu, select the "Export Text As..." option to save the text in the Terminal window to a file. This is limited to what is shown in the window, but can also be used only for selected text.


The "Quartz" features in OS X can be exceptionally useful, with the support for transparent windows being one of them. Since many times you may be entering commands and information into the terminal that you are viewing elsewhere (ie, a web page or a Unix man page in another terminal window), having transparent terminal windows will allow you to cover some of what you are viewing with the Terminal window and still be able to see it. To do this, go to the "Settings" section of the Terminal preferences and in the "Window" tab click the background color square. From here, you can set your color properties, including the the opacity of the window (I use about 80%).

Transparency can conveniently show information behind the current Terminal window

Window Groups

Many times it is most convenient to have several windows open in various layouts for certain tasks. For instance, when creating shell scripts I will many times have two or three windows open to and arranged to view command man pages and another resources during my editing. Setting up this environment every time can be a tad irritating, but saving any current window session as a window group (available in the "Window" menu)will allow you to easily open the desired layout again.

Saved window groups can be useful for specific tasks such as scripting.

There are some limitations to window groups including not preserving split window views, and being limited to only one space.

Split window views

A welcome addition to the Terminal in Snow Leopard is split views, where you can take a current window view and split it so you can scroll up and down in one half of the window and enter commands in the other half. Multiple splits can be done as well, which is useful for coding.

Split windows is a welcome addition to the Terminal in Snow Leopard.

Merge all windows

With window groups or when running a variety of different tasks in separate Terminal windows, there may be times when you would like to preserve your current window session but collect it all into one location. Spaces is an option for this, but the Terminal can also collect every open window into tabs on the foremost window. This can be done by selecting the "Merge All Windows" option in the "Window" menu.

Questions? Comments? Post them below or email us!
Be sure to check us out on Twitter and the CNET Mac forums.