Linux Tab Completion: Ignoring Case Sensitivity

Linux Command Line: Enabling Case-Insensitive Tab Completion
The Linux command line distinguishes between uppercase and lowercase characters. When utilizing tab completion for directories, precise case matching is typically required. However, a configuration adjustment allows for case-insensitive tab completion.
Understanding Tab Completion
Tab completion streamlines directory name entry in the command line. Initiate typing a directory’s beginning, then press Tab to automatically fill in the remainder. For instance, to navigate to the Documents directory, typing cd Docu followed by Tab will expand to
cd Documents/
This feature significantly accelerates command input.
Modifying the .inputrc File
To make tab completion case insensitive, a setting must be added to Linux’s .inputrc file. This file manages keyboard mappings and command line behavior, offering customization options. The process is straightforward.
Two .inputrc files exist: a system-wide version (/etc/.inputrc) and a user-specific version (~/.inputrc). The user-specific file overrides the global one, ensuring your settings take precedence. We will modify the local file in this example.
Editing the Local .inputrc File
A text editor will be used to modify the .inputrc file. Open the Terminal by pressing Ctrl+Alt+T. To edit the local .inputrc file, enter the following command and press Enter:
gksu gedit ~/.inputrc
Alternatively, to modify the global .inputrc file, use this command:
gksu gedit /etc/.inputrc
If the .inputrc file doesn't exist, this command will create it automatically.
A password prompt will appear; enter your login password and click “OK”.
The .inputrc file may initially be empty, which is perfectly acceptable.
Adding the Case-Insensitive Setting
To enable case-insensitive tab completion, add the following line to the file:
set completion-ignore-case on
Then, click "Save".
Close the gedit editor by clicking the “X” button in the upper-left corner.
Activating the Changes
The modification to the .inputrc file won’t immediately affect the current Terminal session. Close and reopen the Terminal window for the changes to take effect. Type exit and press Enter, or click the “X” button.
Note that some warnings may appear during this process, but they are inconsequential to the file modification.
Testing the New Setting
Now, for example, if you type cd docu and press Tab…
…tab completion will function correctly, even with mismatched casing.
Reverting to Case-Sensitive Completion
To restore the default case-sensitive behavior, open the .inputrc file, delete the line you added (set completion-ignore-case on), save, and close the file. Remember to close and reopen the Terminal window after making this change.