2 Bash tricks: TAB-TAB and Case Insensitive Completion

In this article I will show you two bash inputrc tricks.

The first one is: set show-all-if-ambiguous on. Add this to your ~/.inputrc file because it is very usefull. When pressing TAB for command completion, all the matches will be displayed, even if they are ambiguous, as if you have pressed TAB twice (TAB-TAB).

The second one is: set completion-ignore-case on. By adding this to your ~/.inputrcfile, you will make the tab completion incase sensitive.

For example, if you write cd ~/des[TAB] you will get ~/Desktop.

To benefit from this two cool features, add this lines in your ~/.inputrc file. Or, to make this modifications global, add the two lines in the /etc/inputrc file.

$ echo 'set show-all-if-ambiguous on' >> ~/.inputrc
$ echo 'set completion-ignore-case on' >> ~/.inputrc

$ cat ~/.inputrc
set show-all-if-ambiguous on
set completion-ignore-case on

Tagged with: , , , , , , ,
Posted in The Linux and Unix Articles!
One comment on “2 Bash tricks: TAB-TAB and Case Insensitive Completion
  1. Oitos says:

    Awesome, thanks – this is just what I needed to know!

    I usually use ZSH, which can be configured to be case-insensitive, but now I have configured it so I act Tab-Tab and case-insensitivity-Tab everywhere. It’s really useful when switching between users 🙂

    Note the following for achieving global functionality:
    You can add the two parameters from the article directly to /etc/inputrc in order to have this function for all users at all times.

    Follow these steps to do so:

    Log in as root and first make a backup of /etc/inputrc:
    cp /etc/input /etc/inputrc.bak

    To edit /etc/input you have at least two options:

    You can either execute the echo commands from your terminal as root (notice the target is /etc/input instead of your home directory):
    echo ‘set show-all-if-ambiguous on’ >> /etc/inputrc
    echo ‘set completion-ignore-case on’ >> /etc/inputrc

    Or you can open the file in a text editor and add the following manually:
    ### My additions:
    set show-all-if-ambiguous on
    set completion-ignore-case on

    Either way, you will only have to log out and log in in order to test if it’s working correctly. If you are not getting the desired result–and perhaps even having trouble using your keyboard when logged in to your phone–then use the information I have posted below for copying back your original.

    [NOTE: If you run into troubles because you configured /etc/inputrc the wrong way, you can copy/paste the following commands when logged into your phone, in order to replace your edited inputrc file with the original.
    cp /etc/inputrc.bak /etc/inputrc

Leave a Reply

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




Subscribe to get the latest Linux news and how to guides directly on your e-mail!