More concise version
With "\t": menu-complete
in ~/.inputrc
create these two files,
$ touch one.two.txt
$ touch one.four.txt
start writing the following,
$ ls one
hit Tab and you'll get
$ ls one.four.txt
Now move the cursor to just before four
, delete four
, write only t
, and then hit Tab again. You'll get
$ ls one.two.txt.txt
Is there a way to prevent the duplicated .txt
in this workflow?
Original question
I use menu-complete
bash function to cycle through completion when I press Tab, and I'm happy with it. But the following has too often happened to me.
Suppose I'm looking for the file longparthardtoremember.with.QQQQQQQ.extension
in a directory which contains the files
longparthardtoremember.with.AAAAAAA.nice.long.extension
longparthardtoremember.with.BBBBBBB.very.nice.long.extension
...
If I Tab-complete $ long
the first filename will be inserted. At that point, I'd like to move to the middle of the filename, delete the AAAAAAA
part, type B
, and then Tab-complete again. If I do so, all the part after BBBBBBB
is inserted as well, thus leading to a duplication of it, which I obviously don't want.
With vi
editing mode, I'm quite quick in dealing with this (I quickly move to the repeated part and delete it), but it is still annoying.
By pure chance I've find the skip-completed-text
bash option in bash's man page. Isn't this what I need? I've set it on
, but I can't see any difference in the behavior of in-middle-of-work Tab-completion. Have I misunderstood the man page?
Best Answer
skip-completed-text
works this way (with your exampletouch one.four.txt
):If you press tab with
skip-completed-text on
it will complete toIf you press tab with
skip-completed-text off
it will complete toSo this setting does not help you when you edit the middle of the completion.