The best method to simulate this auto-completion behavior is to enable the
show-all-if-ambiguous readline variable (to display the possible completions if more than one match is found), then invoke the completion with the
glob-complete-word readline command (to perform the glob pathname expansion).
# 1: Enable `show-all-if-ambiguous` in ~/.inputrc
set show-all-if-ambiguous on
show-all-if-ambiguous: This alters the default behavior of the completion functions. If set to ‘on’, words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell. The default value is ‘off’.
# 2a: Check to ensure that `glob-complete-word` is bound.
$ bind -q "glob-complete-word"
glob-complete-word can be invoked via "\eg".
# 2b: If unbound, bind `glob-complete-word` to "\eg".
$ bind '"\eg":glob-complete-word'
glob-complete-word (M-g): The word before point is treated as a pattern for pathname expansion, with an asterisk implicitly appended. This pattern is used to generate a list of matching file names for possible completions.
# 3: Trigger the autocompletion with <META-g> or <ESC-g>
# META => alt (Windows/Linux)
# META => option (OSX)
$ ls *2.<META-g>
# possible completions will be listed (show-all-if-ambiguous)
mydoc2.pdf mydoc2.tex mydoc2.txt
# glob pathname completion will be performed (glob-complete-word)
$ ls mydoc2.