To set up filename tab-completion in the Bash shell so that it is case-insensitive, you can use the bind
command to bind the TAB
key to a function that performs case-insensitive tab-completion.
Here is an example of a function that performs case-insensitive tab-completion:
function case_insensitive_tab_completion { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -f -X '!*' -- "$cur" | tr '[:upper:]' '[:lower:]') ) }
To bind this function to the TAB
key, you can use the following command:
bind 'TAB: case_insensitive_tab_completion'
This will cause the Bash shell to use the case_insensitive_tab_completion
function whenever the TAB
key is pressed to perform tab-completion. The function will convert the current completion word to lowercase and use it to generate a list of case-insensitive completions.
To make this change permanent, you can add the bind
command to your ~/.bashrc
file. This will cause the function to be bound to the TAB
key every time you start a new Bash shell.