CHAPTER 10Completion

Shell completion started out in the C shell as a way to save the user effort when typing out long filenames. The user types the first few characters of a filename and presses a special key such as Tab or Esc. The shell then completes the remaining characters of the filename. Consider the following example:

% ls index.html  intro.html  links.html % cat l<tab>

expands to

% cat links.html

As you can see, I want to review links.html, and I only had to type the first letter and then press the Tab key, prompting the shell to complete the filename for me. It's quite a convenient feature indeed!

Modern shells have extended this basic idea well beyond its original scope. All manner of things can be completed: filenames, usernames, ...

Get From Bash to Z Shell: Conquering the Command Line now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.