Command Line Autocomplete

I was working with a fellow aspiring Linux user today on a project with him (yes, I’m talking about you Eric) and I noticed that when he would cd, he would completely type the folder name, even when it was apache-tomcat-6.0.26. If you’ve been using Linux for any amount of time, this might give you a headache because you know about Bash’s autocomplete feature. I mentioned it to him and after seeing what it did, he exclaimed that he had been looking all over for that and was never able to find it.

Note that this little trick works on windows command line as well as linux/unix command line (most shells support some variant of this - bash, zsh, ksh). While the two categories behave slightly differently, it still provides a functionality that is comparable to that of a breath of fresh air in a sewage treatment plant.

For those of you who are impatient, the auto-complete feature of bash is executed with the <tab> key.

How is it used? We’ll use linux for this example.

If you type …

cd /usr/li  &lt;tab&gt;

…the shell will fill in /usr/lib. Now, you will notice that there are two directories in the /usr/ directory that start with lib. If you then proceed to type…

cd /usr/libe  &lt;tab&gt;

…the shell will fill in /usr/libexec.

Neat,  huh?

Category:Linux Category:Bash