Command-line completion

Example of command-line completion in Bash.
Example of command-line completion in PowerShell with Intellisense.

Command-line completion (also tab completion) is a common feature of command-line interpreters, in which the program automatically fills in partially typed commands.

Command line interpreters are programs that allow a user to interact with the underlying operating system by typing commands at a command prompt using a command line interface (CLI), in contrast to pointing and clicking a mouse in a Graphical User Interface (GUI). Command-line completion allows the user to type the first few characters of a command, program, or filename, and press a completion key (normally Tab ↹) to fill in the rest of the item. The user then presses Return or ↵ Enter to run the command or open the file.

Command-line completion is useful in several ways, as illustrated by the animation accompanying this article. Commonly accessed commands, especially ones with long names, require fewer keystrokes to reach. Commands with long or difficult to spell filenames can be entered by typing the first few characters and pressing a completion key, which completes the command or filename. In the case of multiple possible completions, some command-line interpreters, especially Unix shells, will list all possible completions beginning with those few characters. The user can type more characters and press Tab ↹ again to see a new, narrowed-down list if the typed characters are still ambiguous, or else complete the command/filename with a trailing space. An alternate form of completion rotates through all matching results when the input is ambiguous.

Completable elements may include commands, arguments, file names and other entities, depending on the specific interpreter and its configuration. Command-line completion generally only works in interactive mode. That is, it cannot be invoked to complete partially typed commands in scripts or batch files, even if the completion is unambiguous. The name tab completion comes from the fact that command-line completion is often invoked by pressing the tab key.

History

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.

Example

To open the file introduction-to-command-line-completion.html with Firefox one would type:

 firefox introduction-to-command-line-completion.html

This is a long command to type. Instead we can use command-line completion.

Prompting 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:

 fir

Then we press Tab ↹ and because the only command in our system that starts with "fir" is "firefox", it will be completed to:

 firefox

Then we start typing the file name:

 firefox i

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:

 firefox introduction-to-

Now we type "c":

 firefox introduction-to-c

After pressing Tab ↹ it will be completed to the whole filename:

 firefox introduction-to-command-line-completion.html

In short we typed:

 firTab ↹iTab ↹cTab ↹

This is just eight keystrokes, which is considerably less than 52 keystrokes we would have needed to type without using command-line completion.

Rotating 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:

 firefox i

We press Tab ↹ once, with the result:

 firefox introduction-to-bash.html

We press Tab ↹ again, getting:

 firefox introduction-to-command-line-completion.html

In short we typed:

 firTab ↹iTab ↹Tab ↹

This is just seven keystrokes, comparable to prompting-style completion. This works best if we know what possibilities the interpreter will rotate through.

Completion in different command line interfaces

  • Unix shells, including Bash (the default shell in most Linux distributions) and ksh among many others, have a long-standing tradition of advanced and customizable completion capabilities.[3]
    • Bash programmable completion, complete and compgen commands[4] have been available since the beta version of 2.04[3] in 2000[5] and offers at least Pathname and filename completion.
    • For KornShell users, file name completion depends on the value of the EDITOR variable. If EDITOR is set to vi, you type part of the name, and then Escape,\. If EDITOR is set to Emacs, you type part of the name, and then Escape,Escape.
    • The Z shell (zsh) pioneered the support for fully programmable completion, allowing users to have the shell automatically complete the parameters of various commands unrelated to the shell itself, which is accomplished by priming the shell with definitions of all known switches as well as appropriate parameter types. This allows the user to e.g. type tar xzf Tab ↹ and have the shell complete only tarred gzip archives from the actual filesystem, skipping files which are incompatible with the input parameters. A modern zsh installation comes with completion definitions for over five hundred commands.
    • Tcsh offers default file, command, and variable name completion activated using Tab ↹. The 'complete' builtin command provides fully programmable completion. The source code comes with a 'complete.tcsh' file containing many examples of its completion syntax.
  • Windows PowerShell, the extensible command shell from Microsoft, which is based on object-oriented programming and the Microsoft .NET framework, provides powerful and customizable completion capabilities similar to those of traditional Unix shells.[6][7][citation needed]
  • The cmd.exe command processor of Windows NT-based systems supports basic completion. It is possible to use a separate key-binding for matching directory names only.
  • cmd.exe /F:ON enables file and directory name completion characters (^F and ^D by default). Use cmd.exe /? for more information.
  • TweakUI can be used to configure the keys used for file name and directory name completion.[8]
  • The MS-DOS command processor COMMAND.COM did not have command-line completion: pressing the tab key would just advance the cursor. However, various enhanced shells for MS-DOS, such as 4DOS, the FreeDOS version of COMMAND.COM, or the Enhanced DOSKEY.COM feature Unix-style tab completion.
  • Far Manager apart from its file management functions provides command history and line completion for Windows.

See also

References

  1. ^ "Origins and Development of TOPS-20". www.opost.com. Archived from the original on 2020-08-01. Retrieved 2006-09-10.
  2. ^ DECSYSTEM-20 Assembly Language Guide
  3. ^ a b "Working more productively with bash 2.x/3.x". www.caliban.org.
  4. ^ "Bash Reference Manual". tiswww.case.edu.
  5. ^ "Index of /gnu/bash". ftp.swin.edu.au.
  6. ^ "The PowerShell Guy". thepowershellguy.com.
  7. ^ "The PowerShell Guy". thepowershellguy.com.
  8. ^ "Simon Peyton Jones at Microsoft Research". Microsoft.

Unix shells

Windows command interpreters

(Be sure to check the "Applies to" section in each article)

Read other articles:

Russian oligarch and mercenary leader (1961–2023) In this name that follows Eastern Slavic naming conventions, the patronymic is Viktorovich and the family name is Prigozhin. Yevgeny PrigozhinЕвгений ПригожинPrigozhin in 2023Leader of the Wagner GroupIn office22 February 2014 – 23 August 2023Military commanderDmitry UtkinPreceded byPosition establishedSucceeded byPavel Prigozhin[1] Personal detailsBornYevgeny Viktorovich Prigozhin (Евгений Викт

Voce principale: Romanzo criminale - La serie. La seconda stagione della serie televisiva Romanzo criminale - La serie andò in onda in prima visione su Sky Cinema 1 dal 18 novembre al 16 dicembre 2010. In chiaro andò in onda su Italia 1 dal 10 gennaio al 29 febbraio 2012. Logo della serie televisiva nº Titolo italiano Prima TV Italia 1 Episodio 1 18 novembre 2010 2 Episodio 2 18 novembre 2010 3 Episodio 3 25 novembre 2010 4 Episodio 4 25 novembre 2010 5 Episodio 5 2 dicembre 2010 6 Episodi...

The Most ReverendAndrew Sandford HutchisonPrimate Emeritus of the Anglican Church of CanadaArchbishop Hutchison in 2007ChurchAnglican Church of CanadaSeeExtra-diocesanIn office2004–2007PredecessorMichael PeersSuccessorFred HiltzOther post(s)Archbishop of Montreal and Metropolitan of the Ecclesiastical Province of Canada Bishop Ordinary to the Canadian ForcesOrdersOrdination1970Consecration1990Personal detailsBorn (1938-09-19) 19 September 1938 (age 85)Toronto, Ontario, Canada Andrew Sa...

Keuskupan San Benedetto del Tronto-Ripatransone-MontaltoDioecesis Sancti Benedicti ad Truentum-Ripana-Montis AltiKatolik Katedral San Benedetto del TrontoLokasiNegaraItaliaProvinsi gerejawiFermoStatistikLuas456 km2 (176 sq mi)Populasi- Total- Katolik(per 2010)137.135130,696 (95.3%)Paroki54InformasiDenominasiGereja KatolikRitusRitus RomaPendirian1 Agustus 1571 (452 tahun lalu)KatedralBasilica Cattedrale di S. Maria della Marina (San Benedetto del Tronto)Konka...

Coordenadas: 46° 44' N 0° 55' E Néons-sur-Creuse   Comuna francesa    Localização Néons-sur-CreuseLocalização de Néons-sur-Creuse na França Coordenadas 46° 44' N 0° 55' E País  França Região Centro-Vale do Loire Departamento Indre Características geográficas Área total 19,58 km² População total (2018) [1] 383 hab. Densidade 19,6 hab./km² Código Postal 36220 Código INSEE 36137 Néons-sur-Creuse é uma comuna france...

يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (مارس 2016) هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (�...

Protestors carrying a mosaic of national flags bearing the Guerrillero Heroico likeness of Che Guevara. The legacy of Argentine Marxist revolutionary Che Guevara (June 14, 1928 – October 9, 1967) is constantly evolving in the collective imagination. As a symbol of counterculture worldwide, Guevara is one of the most recognizable and influential revolutionary figures of the twentieth century. However, during his life, and even more since his death, Che has elicited controversy and wildly div...

Open-source web browser project For other uses, see Chromium (disambiguation). ChromiumChromium version 119Original author(s)Google[1]Developer(s)The Chromium Projects[2]Initial release2 September 2008; 15 years ago (2008-09-02)[1]Repositorychromium.googlesource.com/chromium/src Written inC++ primarily,[3] HTML, CSS, JavaScript for UI and test suite[4][5]EnginesBlink, V8Operating systemWindows, Linux, Android, iOS, macOS, BSDPl...

Place in Castile and León, SpainTudela de DueroView of Tudela de Duero. SealTudela de DueroShow map of Castile and LeónTudela de DueroShow map of SpainCoordinates: 41°35′03″N 4°34′48″W / 41.58417°N 4.58000°W / 41.58417; -4.58000CountrySpainAutonomous communityCastile and LeónProvinceValladolidMunicipalityTudela de DueroArea • Total60 km2 (20 sq mi)Population (2018)[1] • Total8,547 • Density1...

Indigenous Australian professional rugby league footballer James RobertsPersonal informationFull nameJames Nathanial RobertsBorn (1993-03-03) 3 March 1993 (age 30)Kempsey, New South Wales, AustraliaPlaying informationHeight183 cm (6 ft 0 in)Weight90 kg (14 st 2 lb)PositionCentre, Wing Club Years Team Pld T G FG P 2011 South Sydney 10 5 0 0 20 2013 Penrith Panthers 6 6 0 0 24 2014–15 Gold Coast Titans 36 21 1 0 86 2016–19 Brisbane Broncos 81 41 0...

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada November 2022. Nama ini menggunakan kebiasaan penamaan Filipina; nama tengah atau nama keluarga pihak ibunya adalah Sionil dan marga atau nama keluarga pihak ayahnya adalah José. F. Sionil JoséJosé in 2017LahirFrancisco Sionil José(1924-12-03)3 Desember 192...

Эту страницу предлагается объединить со страницей Формула-Рено 1.6.Пояснение причин и обсуждение — на странице Википедия:К объединению/8 июня 2021.Обсуждение длится не менее недели (подробнее). Не удаляйте шаблон до подведения итога обсуждения. Формула Рено — класс форм�...

Deathstalker Rebellion Cover of the 1996 first edition UK paperback release of Deathstalker RebellionAuthorSimon R GreenCover artistSteve CrispCountryUnited KingdomLanguageEnglishSeriesDeathstalkerGenreScience fictionPublisherGollancz/VistaPublication date1996 (1st edition)Media typePrint (paperback)Pages568ISBN0-575-60011-XOCLC34731181Preceded byDeathstalker Followed byDeathstalker War  Deathstalker Rebellion is a science fiction novel by British author Simon R ...

This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: Coincidence circuit – news · newspapers · books · scholar · JSTOR (February 2023) In physics and electrical engineering, a coincidence circuit or coincidence gate is an electronic device with one output and two (or more) inputs. The output activates o...

Hubungan Rusia dengan Uni Eropa Rusia Uni Eropa Hubungan Rusia dengan Uni Eropa adalah hubungan internasional antara Uni Eropa (UE) dan tetangga terbesarnya di sebelah timur, yaitu Rusia.[1] Meskipun hubungan tiap-tiap negara dalam Uni Eropa dengan Rusia berbeda-beda, namun Uni Eropa sendiri telah menentukan kerangka hubungan antara Uni Eropa dan Rusia, kerangka hubungan antara keduanya sering dikenal dengan Ruang Bersama UE-Rusia.[2] Kerangka hubungan ini terbagi dalam empat ...

Antoine BauméAntoine BauméLahir(1728-02-26)26 Februari 1728Senlis, Oise, PrancisMeninggal15 Oktober 1804(1804-10-15) (umur 76)Paris, PrancisKebangsaanPrancisDikenal atasSkala BauméAntoine Baumé (26 Februari 1728 – 15 Oktober 1804) adalah seorang kimiawan Prancis. Ia lahir di Senlis. Ia belajar pada kimiawan Claude Joseph Geoffroy dan pada tahun 1752 diterima sebagai anggota École de Pharmacie. Pada tahun yang sama, ia ditunjuk menjadi profesor kimia di sana. Uang yan...

Este artigo ou secção necessita de referências de fontes secundárias fiáveis e independentes. Fontes primárias, ou com conflitos de interesse, não são adequadas para verbetes enciclopédicos. Ajude a incluir referências.—Encontre fontes: ABW  • CAPES  • Google (N • L • A) (Março de 2022) Coordenadas: 23º18'33.69S 51°09'00.66W Terminal Rodoviário José Garcia Villar Terminal Rodoviário de LondrinaVisão das plataform...

Северная Земля Снимок со спутника. Ярко-белые пятна на тёмном фоне — ледники. Июль 2001 года. Характеристики Крупнейший островОстров Октябрьской Революции  Общая площадь37 000 км² Население0 чел. Расположение 80°00′ с. ш. 97°00′ в. д.HGЯO Омывающие акваторииК�...

3-Hydroxyisobutyryl-CoA Names IUPAC name 3′-O-Phosphonoadenosine 5′-[(3R)-3-hydroxy-4-({3-[(2-{[(2Ξ)-3-hydroxy-2-methylpropanoyl]sulfanyl}ethyl)amino]-3-oxopropyl}amino)-2,2-dimethyl-4-oxobutyl dihydrogen diphosphate] Systematic IUPAC name O1-{[(2R,3S,4R,5R)-5-(6-Amino-9H-purin-9-yl)-4-hydroxy-3-(phosphonooxy)oxolan-2-yl]methyl} O3-[(3R)-3-hydroxy-4-({3-[(2-{[(2Ξ)-3-hydroxy-2-methylpropanoyl]sulfanyl}ethyl)amino]-3-oxopropyl}amino)-2,2-dimethyl-4-oxobutyl] dihydrogen diphosphate Identif...

Species of virus Hendra henipavirus Colored transmission electron micrograph of a Hendra henipavirus virion (ca. 300 nm length) Virus classification (unranked): Virus Realm: Riboviria Kingdom: Orthornavirae Phylum: Negarnaviricota Class: Monjiviricetes Order: Mononegavirales Family: Paramyxoviridae Genus: Henipavirus Species: Hendra henipavirus Hendra virus (Hendra henipavirus) is a zoonotic virus found solely in Australia. First isolated in 1994, the virus has since been connected to nu...