Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How can I make the autocompletion for files and folders in the bash shell work case-insensitively?

Ideally, cd ~/doc + tab autocompletes to cd ~/Documents (correcting the case as it autocompletes), but if that's not possible autocompleting to cd ~/documents is acceptable too.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You can do that by typing the following command in the terminal:

echo 'set completion-ignore-case On' >> ~/.inputrc

if you want to go back to the original behavior you have the open that file and remove the line.

The file ~/.inputrc file deals with mapping the keyboard for specific situations. This file is the start-up file used by Readline, the input-related library used by Bash, perl and most other open source programs.

The configuration options in .inputrc are particularly useful for customising the way Tab-completion works, e.g. with the ls command

When a program which uses the Readline library starts up, the init file is read, and the key bindings are set.

You can find more information about the file syntax in "Bash startup files".

share|improve this answer
    
Ty, this works. Out if curiosity, is there a reason why this doesn't work when added to ~/.bash_profile for example? –  Gerry Oct 15 '12 at 15:29
    
@Gerry I noticed the same by adding it to .profile (correct it if I'm wrong). In my opinion this is because Readline read the .inputrc or /etc/inputrc and not other files. However I'm not completely sure about that. –  Maverik Oct 15 '12 at 15:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.