Reputation: 13143
I was looking for a tweak to the cd command so that it recognizes spelling mistakes of directories and auto complete similar directory names.
Right now, I have settings that recognize the spelling mistakes of directory but does not auto complete them.
For directory spelling mistake correction I have this code in ~/.bashrc
:
shopt -s cdspell
Now it works in the following manner, suppose I have a directory called "trash"
vickey@home:~$ cd tras
trash
vickey@home:~/trash$ cd ..
vickey@home:~$ cd trasx
trash
vickey@home:~/trash$ pwd
/home/vickey/trash
vickey@home:~/trash$
vickey@home:~$ cd Trash
trash
vickey@home:~/trash$ pwd
/home/vickey/trash
But the problem I have is suppose I make a directory called Temp and do something like
vickey@home:~$ mkdir Temp
vickey@home:~$ cd temp
Temp
vickey@home:~/Temp$ cd ..
vickey@home:~$ cd te #and tab here
test/ textin/
it does not show Temp
as an option. Is there anyway to make auto completion case insensitive?
Upvotes: 21
Views: 5317
Reputation: 23680
Completion is a feature of readline
.
You can enable case insensitive completion either by:
1) Adding to your ~/.bashrc
:
bind 'set completion-ignore-case on'
OR
2) Adding to your /etc/inputrc
:
set completion-ignore-case on
Notes:
/etc/inputrc
, as @mak comments, effects all shells that use readline
, and not just bash
.
This will make all completions case insensitive.
Upvotes: 27