Tab completion showed up early in computing history; one of the first examples appeared in the Berkeley Timesharing System for the SDS 940, where if a typed string were ambiguous, the interpreter would do nothing, but if the string was not ambiguous, it would automatically complete it without any command from the user. This feature did not work well with the all too frequent typos, and so was a mixed blessing. This feature was imitated by Tenex's developers who made an important change: Tenex used "escape recognition", in which the interpreter would not attempt to autocomplete unless the escape key was struck (thus the name) by the user. The domain was also expanded from only program names on the Berkeley system to both program names and files on Tenex.1 The Tenex descendant TOPS-20 moved command line completion from command interpreter to the operating system via the COMND JSYS system call, to make it available to other user applications.2 From there it was borrowed by Unix.
To open the file introduction-to-command-line-completion.html with Firefox one would type:
This is a long command to type. Instead we can use command-line completion.
The following example shows how command-line completion works in Bash. Other command line shells may perform slightly differently.
First we type the first three letters of our command:
Then we press Tab ↹ and because the only command in our system that starts with "fir" is "firefox", it will be completed to:
Then we start typing the file name:
But this time introduction-to-command-line-completion.html is not the only file in the current directory that starts with "i". The directory also contains files introduction-to-bash.html and introduction-to-firefox.html. The system can't decide which of these filenames we wanted to type, but it does know that the file must begin with "introduction-to-", so the command will be completed to:
Now we type "c":
After pressing Tab ↹ it will be completed to the whole filename:
In short we typed:
This is just eight keystrokes, which is considerably less than 52 keystrokes we would have needed to type without using command-line completion.
The following example shows how command-line completion works with rotating completion, such as Windows's CMD uses.
We follow the same procedure as for prompting completion until we have:
We press Tab ↹ once, with the result:
We press Tab ↹ again, getting:
This is just seven keystrokes, comparable to prompting-style completion. This works best if we know what possibilities the interpreter will rotate through.
(Be sure to check the "Applies to" section in each article)
"Origins and Development of TOPS-20". www.opost.com. Archived from the original on 2020-08-01. Retrieved 2006-09-10. https://web.archive.org/web/20200801165237/http://www.opost.com/dlm/tenex/hbook.html ↩
DECSYSTEM-20 Assembly Language Guide http://kermit.columbia.edu/kermit/dec20/assembler-guide.txt ↩
"Working more productively with bash 2.x/3.x". www.caliban.org. http://www.caliban.org/bash/index.shtml ↩
"Bash Reference Manual". tiswww.case.edu. https://tiswww.case.edu/php/chet/bash/bashref.html#Programmable-Completion ↩
"Index of /gnu/bash". ftp.swin.edu.au. https://ftp.swin.edu.au/gnu/bash/ ↩
"The PowerShell Guy". thepowershellguy.com. http://thepowershellguy.com/blogs/posh/archive/2007/06/02/powertab-flash-exampes.aspx ↩
"The PowerShell Guy". thepowershellguy.com. http://thepowershellguy.com/blogs/posh/pages/powertab.aspx ↩
"Simon Peyton Jones at Microsoft Research". Microsoft. https://www.microsoft.com/en-us/research/people/simonpj/ ↩