Bash – Make Bash autocomplete guess the closest approximation

autocompletebash

I have a somewhat uncomfortable keyboard on my laptop, resulting in that I sometimes misspell things in Bash and when pressing Tab for an auto-completion nothing happens.

Is it possible to have Bash guess what I meant to type, by for example when wanting to change directory to Documents and then mistyping cd ocum[TAB], given no other folder beginning with "ocum" is present, Bash interprets it as cd Documents/ since it is the closest possible action to do?

Or is this idea terribly complicated to achieve?

Best Answer

On github there's an 11K fuzzy_bash_completion script that appears to match some of the spec:

For example:

mkdir pizza
mkdir jazz
cd zz<TAB>
# displays `pizza' and `jazz'
rm -r jazz
cd zz<TAB>
# completes the word `pizza'