Can I make Tab auto-completion case-insensitive in Bash?
In order to make bash
case-insensitive for to current user:
Run the following shell script in a terminal:
# If ~/.inputrc doesn't exist yet: First include the original /etc/inputrc
# so it won't get overriden
if [ ! -a ~/.inputrc ]; then echo '$include /etc/inputrc' > ~/.inputrc; fi
# Add shell-option to ~/.inputrc to enable case-insensitive tab completion
echo 'set completion-ignore-case On' >> ~/.inputrc
Start a new shell (reopen the terminal).
To Make the changes systemwide:
# add option to /etc/inputrc to enable case-insensitive tab completion for all users
echo 'set completion-ignore-case On' >> /etc/inputrc
# you may have to use this instead if you are not a superuser:
echo 'set completion-ignore-case On' | sudo tee -a /etc/inputrc
For details, see man bash
. Yes it is a long page, but bash is a somewhat complex program, and if you want just search that page for "case-insensitive" to go to the relevant section. People usually learn bash one option at a time or one bash script at a time and it takes a long time to master all the nuances. Your interest may vary.
Open a terminal and type the below command:
echo set completion-ignore-case on | sudo tee -a /etc/inputrc
Enter password. Restart terminal.
If in some case you want to remove case insensitive, just edit /etc/inputrc file by removing the set completion-ignore-case
line.
That's all.
I know this question is very old but unless I am missing something I think I have a super simple solution if you are using bash.
echo "bind 'set completion-ignore-case on'" >> ~/.bashrc
Or just add the line using your favorite text editor. Restart your bash session and enjoy.