Auto completion at the end / middle of a line in bash

There is a quick way in bash to make tab completion automatically based on the middle of a word.

So, for example, if I have these files in a directory:

001_apple.txt 002_pear.txt 003_dog.txt 

I would like to enter the sequence: *d<TAB>to automatically end 003_dog.txt.

Can this be done in bash? Is it easier to do this in other shells?

+5
source share
5 answers

Try ESC-g to expand the globe.

And you should always install the bash -completion package (usually the default, but you need to specify it in your bash script profile).

+3
source

, zsh . . COMPLETE_IN_WORD.

Fish .

+2
ls *d*<TAB>

works in bash. Not sure what that means Ben. lscan, of course, be any other team.

+2
source

You can replace it `ls *d*`  to achieve the same effect, which is not as convenient as performing a tab, however

0
source

I think this is a readline function (maybe not even a default binding):

enter ls \*middle\*, then enter ctrl-x, *will replace \*middle\*with files matching the pattern.

0
source

All Articles