Skip to content

Commit

Permalink
completion: pip: Only invoke pip when trying to complete it
Browse files Browse the repository at this point in the history
This should greatly reduce shell load time, as the pip invocation takes
a lot of time
  • Loading branch information
Noah Gorny committed Aug 3, 2021
1 parent db318cd commit 61c0357
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion completion/available/pip.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion completion/available/pip3.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 61c0357

Please sign in to comment.