diff --git a/completion/available/pip.completion.bash b/completion/available/pip.completion.bash index ad3abb7e..618909ad 100644 --- a/completion/available/pip.completion.bash +++ b/completion/available/pip.completion.bash @@ -1,11 +1,10 @@ - -# pip bash completion start -_pip_completion() -{ - COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ - COMP_CWORD=$COMP_CWORD \ - PIP_AUTO_COMPLETE=1 $1 ) ) -} -complete -o default -F _pip_completion pip -# pip bash completion end - +# https://pip.pypa.io/en/stable/user_guide/#command-completion +# Of course, you should first install the pip, say on Debian: +# sudo apt-get install python-pip +# sudo apt-get install python3-pip +# If the pip package is installed within virtual environments, say, python managed by pyenv, +# you should first initilization the corresponding environment. +# So that the pip/pip3 is in system's path. +if command -v pip >/dev/null; then + eval "$(pip completion --bash)" +fi diff --git a/completion/available/pip3.completion.bash b/completion/available/pip3.completion.bash index 1800756b..599e96e5 100644 --- a/completion/available/pip3.completion.bash +++ b/completion/available/pip3.completion.bash @@ -1,11 +1,11 @@ - -# pip bash completion start -_pip_completion() -{ - COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ - COMP_CWORD=$COMP_CWORD \ - PIP_AUTO_COMPLETE=1 $1 ) ) -} -complete -o default -F _pip_completion pip3 -# pip bash completion end +# https://pip.pypa.io/en/stable/user_guide/#command-completion +# Of course, you should first install the pip, say on Debian: +# sudo apt-get install python-pip +# sudo apt-get install python3-pip +# If the pip package is installed within virtual environments, say, python managed by pyenv, +# you should first initilization the corresponding environment. +# So that the pip/pip3 is in system's path. +if command -v pip3 >/dev/null; then + eval "$(pip3 completion --bash)" +fi