completion: pip: Only invoke pip when trying to complete it

This should greatly reduce shell load time, as the pip invocation takes
a lot of time
pull/1834/head
Noah Gorny 2021-02-06 23:29:18 +02:00
parent db318cdd3e
commit 61c0357414
2 changed files with 18 additions and 2 deletions

View File

@ -7,5 +7,13 @@
# you should first initialize the corresponding environment.
# So that pip is in the system's path.
if _command_exists pip; then
eval "$(pip completion --bash)"
function __bash_it_complete_pip() {
if _command_exists _pip_completion; then
_pip_completion "$@"
else
eval "$(pip completion --bash)"
_pip_completion "$@"
fi
}
complete -o default -F __bash_it_complete_pip pip
fi

View File

@ -7,5 +7,13 @@
# you should first initialize the corresponding environment.
# So that pip3 is in the system's path.
if _command_exists pip3; then
eval "$(pip3 completion --bash)"
function __bash_it_complete_pip3() {
if _command_exists _pip_completion; then
_pip_completion "$@"
else
eval "$(pip3 completion --bash)"
_pip_completion "$@"
fi
}
complete -o default -F __bash_it_complete_pip3 pip3
fi