This post was originally published on go2linux.org on August 10, 2009. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.

The problem

Linux file and directory names are case-sensitive. If you have a directory named My-Documents, tab completion only works when you type the right case:

cd My-[TAB]     # works → My-Documents
cd my-[TAB]     # fails — nothing happens

The fix — set completion-ignore-case

Add this line to ~/.inputrc (your personal readline config):

set completion-ignore-case on

Then either open a new terminal, or apply the change in the current session:

bind -f ~/.inputrc

Now tab completion works regardless of case:

cd my-[TAB]     # completes to My-Documents
cd MY-[TAB]     # also works

System-wide vs per-user

File Scope
~/.inputrc Current user only (recommended)
/etc/inputrc All users on the system

If you want to apply the setting for all users, edit /etc/inputrc as root. The syntax is the same.

Other useful readline settings

While you have .inputrc open, these settings are commonly useful:

Show all completions immediately if there is any ambiguity (no need to press TAB twice):

set show-all-if-ambiguous on

Color file completions by type (like ls --color):

set colored-stats on

Append a / to directory completions:

set mark-directories on

Highlight the completed portion in color:

set colored-completion-prefix on

A complete ~/.inputrc example

set completion-ignore-case on
set show-all-if-ambiguous on
set colored-stats on
set mark-directories on
set colored-completion-prefix on

Save the file, then run bind -f ~/.inputrc to apply without restarting.

Verify with bind

You can check the current readline settings at any time:

bind -v | grep completion-ignore-case

Output if enabled:

set completion-ignore-case on

See also

  • man readline — full reference for all readline settings
  • bind -l — list all readline functions
  • bind -p — list all current key bindings