Cycle through autocomplete options in Ubuntu’s Terminal with the TAB key

The Terminal in Ubuntu, a.k.a. bash shell or console, autocompletes file names when the TAB key is pressed. On multiple hits, however, it lists all the options and waits for more inputs to disambiguate.

For instance, in my home directory I have a directory called Documents and another called Downloads. When I type Do and press TAB, nothing happens. Pressing TAB again shows Downloads and Documents, and now I must either type c or w to choose between them. I personally prefer the Windows Command Line style, where tabbing the first time cycles through Documents and Downloads.

To change to the cyclic completion behaviour, simply edit the .bashrc file in your home directory. To change for all users, edit the /etc/bash.bashrc file. Add the following line:

bind '"\t":menu-complete'

Then restart Terminal and you’re done!

P.S. You might also want to see how to make Terminal’s autocompletion case-insensitive.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>