How do I get bash tab-completion to stop escaping glob wildcards at the beginning of the argument?

Viewed 243

When I try to use tab-completion in bash for a file glob pattern starting with either ? or *, I get the list of completion options as intended, but then my command prompt is modified to escape the glob special character.

For example:

$ ls *.txt                  # tab-complete instead of enter
bar.txt  fib.txt  foo.txt
$ ls \*.txt                 # now my '*' is escaped

And:

$ ls ???.txt                # tab-complete
bar.txt  fib.txt  foo.txt
$ ls \?\?\?.txt             # please stop

How do I get it to stop escaping the special characters when I trigger tab-completion?

This doesn't happen when the * or ? special character is not at the start of the pattern for completion:

$ ls f*.txt       # tab-complete
fib.txt  foo.txt
$ ls f*.txt       # my prompt doesn't change. This is what I want.

This problem seems very similar to:

None of the solutions seem to address my problem, though.

Some info about my setup:

  • My ~/.inputrc contains (pretty much exclusively) set editing-mode vi and set show-all-if-unmodified on.
  • I'm using bash version 5.0.17(1)-release (x86_64-pc-linux-gnu).
  • I uninstalled bash-completion because it was causing me another problem with tab-completion. (Tab-completion changed my prompt to use the first match rather than showing me the options. I got the idea to uninstall it from https://unix.stackexchange.com/a/278449/439902 .)
0 Answers
Related