[Bash-completion-devel] Towards dynamic completion loading

Ville Skyttä ville.skytta at iki.fi
Sun Sep 25 19:07:27 UTC 2011


Hello,

Even though we don't have a roadmap item for dynamic completion loading
(bash 4+'s complete -D), I'd like to start implementing it.

What I'm currently thinking is basically:

1) Start splitting stuff in completions/ into smaller, preferably
per-command files.  This is quite straightforward step for a lot of
cases, and shouldn't be that intrusive change even though the rest of
the steps would for some reason be delayed.

2) Get rid of "have foo" in all completion files that are to be loaded
dynamically.

3) Add our "default completion loader" function.

4) Figure out a good way to handle completions that are installed for
multiple commands.  I think doing this via symlinks (when "make" is run)
would work for both "make install" cases as well as when running from a
git working directory.

5) Add a convenient/consistent way to dynamically load functions from
other completions.  For example the apt completion uses
_rpm_installed_packages in some scenarios - previously this wasn't an
issue because if rpm is installed, _rpm_installed_packages was defined
at bash_completion load time, but now the loading needs to happen
dynamically.  It doesn't have to be any more fancy than something like
"declare -F _rpm_installed_packages &>/dev/null || .
${BASH_SOURCE[0]%/*}/rpm" I think.

6) Make necessary adjustments to the test suite.

Anything else?  I have a bunch of completions that don't need anything
from other files already split up locally (see 1) above) and unless
there are objections, I'm going to commit that to master soon.



More information about the Bash-completion-devel mailing list