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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.