Case Insensitive Tab Completion

If you use the Terminal a lot, you might find this tip handy.

Normally if I want to change to the Sites/ directory, I would type cd Si<tab>. By hitting tab, the following command would be given, cd Sites/. Exactly what I was looking for.

However, if I typed cd si<tab>, the command wouldn’t be completed because it didn’t find any folders that started with “si”.

Here’s where insensitivity comes in.

To make it so we can type cd si<tab> and get cd Sites/ we have to change a variable called completion-ignore-case:

set completion-ignore-case on

However, I had to use the following command to get it to work on my Mac:

bind "set completion-ignore-case on"

Now you should be able to use tab to complete even insensitive cases.

Note: If you’d like to start terminal with this setting, simply add the command to .bashrc or .bash_profile and login/logout.

Note: This is for Bash only

[Via Thomas Ingham]


 
 

3 Responses to “Case Insensitive Tab Completion”

  1. Two related settings that I like are:

    set bell-style none
    set show-all-if-ambiguous On

    the first turns off the rather annoying bell that you get when bash runs into multiple completion options

    and the second shows everything that will match that you start to type

  2. Thanks for the tips Jason, those should definitely come in handy.

  3. Put these in your .inputrc rather than your, for example, .bashrc or .bash_profile, and it will affect all programs that use the "readline" library, including bash. In that case, you can use the directly, without the 'bind "..."' wrapper.

Post a comment to "Case Insensitive Tab Completion"



Support MacTips

MacTips Newsletter


Random Popular Tips

Recent Comments

Recent Discussions

MacTips Poll

What level of tips would you like to see?

View Results

Loading ... Loading ...

Friends of MacTips

Subscribe to MacTips

Site Links