3

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?

4
  • Guessing is hard for computers; could you come up with some patterns you’d like it to try? For example, substituting a missing initial character.
    – Jeff Schaller
    Commented Jan 29, 2018 at 0:02
  • I think in most cases this guessing mechanism would be helpful is when actually changing directories. That is when I type sluggish and in a hurry. Following the example above, cd *ments* does what I want. But using wildcards every time kind of beats the purpose of doing things fast.
    – E. l4d3
    Commented Jan 29, 2018 at 15:56
  • 1
    It's not terribly complicated. The Z shell, if configured to do so, can do exactly the completion described in the question.
    – JdeBP
    Commented Jan 30, 2018 at 13:23
  • zstyle ':completion:*' matcher-list 'b:=*'
    – thrig
    Commented Feb 11, 2018 at 18:35

1 Answer 1

4

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'
1
  • I tested it, and it does the job
    – E. l4d3
    Commented Feb 8, 2018 at 23:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .