Auto Completion

Never Type the Full Name Again

Once you learn to use the tab key you will continue using it for the rest of your life. It may be one of the most powerful additions to the terminal because it makes your job so much easier. Not to mention it reduces typing mistakes and may even help you remember or introduce you to commands or programs you forgot or did not remember.

There are a number of uses for the tab key and I will break them all down individually. First it is hard for me to show you when I push the tab key so I will denote pushing the tab key as [TAB], so you know when to push the key. Lets use my usual example to show how great autocompletion is:

% ls
examples firstDir helloWorld.txt secondDir
% cd f[TAB]

After pushing tab your command should have been autocompleted to show:

% cd firstDir/

See how easy it was the complete the command! That was because the only file or directory inside the current folder starting with an 'f' was firstDir. Now lets see some more advantages of the tab key, listing all you options:

% [TAB][TAB]
Display all 3356 possibilities? (y or n) n
% cd[TAB][TAB]
cd cdda2wav cdrecord
cdc cddb-slave2-properties cdrw
% cd [TAB][TAB]
examples/ firstDir/ helloWorld.txt secondDir/
% mkdir f[TAB]/insideFirstDir
% cd f[TAB]/
hello.txt insideFirstDir/
% cd f[TAB]/i[TAB]/
% pwd
/home/joe/firstDir/insideFirstDir

Which translated to this on my screen:

%
Display all 3356 possibilities? (y or n) n
% cd
cd cdda2wav cdrecord
cdc cddb-slave2-properties cdrw
% cd
examples/ firstDir/ helloWorld.txt secondDir/
% mkdir firstDir/insideFirstDir
% cd firstDir/
hello.txt insideFirstDir/
% cd firstDir/insideFirstDir/
% pwd
/home/joe/firstDir/insideFirstDir

You can see the few points where I listed my options. For instance if I wanted to list all the commands and files or directories in the current directory starting with 'z' you would push z[TAB][TAB]. That would list all your options, and likewise for more letter combinations like st[TAB][TAB] for those starting with 'st'.

Also, notice that the autocompletion feature also worked inside of another directory, correctly for that directory. The last example usage showed that inside firstDir we quickly identified the options availabe to the cd command for that directory.

Use This Feature Often

So here you can discover commands and use the man pages to learn how to use those commands. You can type commands faster and with less mistakes.

up and down »