Mac OS X Command Line Tab Completion

Posted September 22, 2004 by macster in Apple Mac

The command line completion feature is turned on by default on Mac OS X systems. You only need to know how to use it.


When typing a command in the shell of a terminal window, you can simplify your life with the file/directory tab autocompletion feature. Consider that the current directory contains these two directories: Backup files and Books. If you want to switch into the Backup Files directory, type the following:

cd Ba

Here, represents the tab key. Note that if you just type cd B, there is ambiguity since there are two matches. In this case, the shell will list the matches and return you to the same command line state as before you typed the tab key.

A common problem in using command line interfaces on systems with graphical interfaces is that spaces in filenames, while simple in a GUI, complicate things in a command line because shells typically use a space to separate command line parameters. The shell is smart enough to place a backslash before a space in the subsequent autocompleted command line, so the finished command will become as follows:

cd Backup\ files

The Conversation

Follow the reactions below and share your own thoughts.