The sad part of my answer is: bash (via readline) has so many possibilities for completion. But a normal Linux distro can disturb the basic filename expansion with [tab] (or [tab][tab]) by adding option expansion. In my case it is the package "bash-completion" that gives me the behaviour described in the original Q.
It is not only a
openvpn problem. Q says: "for example".
bind -p | grep complete I get:
# menu-complete (not bound)
This is where TAB = ctrl-i is bound to the basic
complete function. The other bindings on my archlinux I just tried out. With "ta[esc][star]" I can get all commands starting with "ta" inserted on my command line.
complete readline function is explained in man bash:
Attempt to perform completion on the text
before point. Bash attempts completion treating the text as a variable
(if the text begins with $), username (if the text begins with ~),
hostname (if the text begins with @), or command (including aliases
and functions) in turn. If none of these produces a match, filename
completion is attempted.
I can only partly reproduce this. I think man bash forgets to mention it depends on whether you [tab] a first word or a 2nd, 3rd etc. word.
I have files starting with "ba" in my home/working dir. When I type "ba[tab]" at the prompt, I do not get these names, only commands from
bashbug. This is a sane behaviour: first word gives you commands, the following words filenames. And if you type "$[tab]" you really get a nice list of variable names.
Actually when I say [tab], I mean [tab][tab]. But we get so used to this that we don't even notice what this "complete" readline function all does. With the "complete-"
variations you can control what is searched for (command, filename, variable) and what to do with the list if there is more than one match (possibility).
These readline functions come with many default bindings. Both
man bash and
man readline list the functions and their default bindings. To check use bind -p as above. This is also the basis for the
~/.inputrc file. I just made one (there was only a cryptic /etc/inputrc):
set colored-completion-prefix on
set colored-stats on
With colored-stats I get a colored list, as with
ls --color. After "bi[tab][tab]" I see "bind" in white and "bison" in green, telling me that "bind" is not a executable (but a built-in...this is COMMAND expansion..."bind" is not even a filename!).
set show-all-if-ambiguous on
This controls tab vs. double tab. After I add it and type
I directly get a colored list of all FILE names. Directories, links, normal files etc. all appear in their own color.
These readline variables you can see with
bind -v. To test a .inputrc change start a new bash with "bash", and then exit. Or Re-login.
The next layer is in
It contains per command scripts, mostly from util-linux and systemd packages. There is a mount (2 Kb) and a systemctl (13 Kb) file. The mount-file is interesting: it gives you /proc/filesystems after you type "-t".
Normally after "mount -t [tab]" I get FILENAMES. After I source that "mount" file I really get fs types like ext2, ext3 and ext4. I go:
complete -r mount
to remove this feature. (THIS
complete is a shell builtin command)
Third layer is that extra "bash-completion" package. I already deinstalled it after I had installed it for testing. With this package I got this nice feature of expanding options, and also package names. I could type "tar --[tab]" and i see all the options. But the filename expansion got lost in many constellations. Amd not only on archlinux.
This bash-completion package gave me a 2000-line script "bash_completion" and a lot of command files. The one for "tar" was 700 lines, full of functions. So fixing this is no solution.
If you really care for these [tab] complete subtleties, you have to start at the bottom and choose one or two readline functions other than
complete to bind to other keys than [tab]. My default configuration above really works, but I have never used anything but [tab]. Now I want to set the right functions to the right keys. With or without that option-expanding bash-completion package.