[Bash-completion-devel] Why bash-completion does not use "complete -D"??
Oleksandr Gavenko
gavenkoa at gmail.com
Sun Aug 14 20:37:16 UTC 2011
Under bash/CHANGES you can read:
g. New complete/compgen/compopt -D option to define a `default' completion:
a completion to be invoked on command for which no completion has been
defined. If this function returns 124, programmable completion is
attempted again, allowing a user to dynamically build a set of
completions
as completion is attempted by having the default completion function
install individual completion functions each time it is invoked.
Under bash-completion/TODO you can read:
An even better alternative would be if bash supported dynamic loading of
shell
functions (in the manner of zsh), but I don't believe there are any plans to
add this feature.
Why this need?
Several times under Cygwin mail list users report bash loading slow
down because bash-completion. Usual recomendation is to disable
bash-completion.
Under my host:
$ time . /etc/bash_completion
real 0m2.239s
user 0m0.653s
sys 0m1.274s
This deley can reach 5-7 sec or moew on first bash_completion load.
Under Linuxes this is not issue because delay less then 1 sec.
Bash lost interactivity for quick task (open terminal with bash
inside, type several commands and close terminal).
Dirty hack:
_completion_loader()
{
. "$BASH_COMPLETION_DIR/$1" && return 124
}
complete -D -F _completion_loader
with commenting:
if [[ -d $BASH_COMPLETION_COMPAT_DIR && -r
$BASH_COMPLETION_COMPAT_DIR && \
-x $BASH_COMPLETION_COMPAT_DIR ]]; then
for i in $(LC_ALL=C command ls "$BASH_COMPLETION_COMPAT_DIR"); do
i=$BASH_COMPLETION_COMPAT_DIR/$i
[[ ${i##*/} !=
@(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)|Makefile*) \
&& -f $i && -r $i ]] && . "$i"
done
fi
and
unset -f have
take working complation (may be with minor issue) with:
$ time . /etc/bash_completion
real 0m0.609s
user 0m0.093s
sys 0m0.370s
What plans to incorporate -D to 'bash_completion'?
Who is interesting in this changes?
More information about the Bash-completion-devel
mailing list