Fix pip completion for running it within/outside of pyenv/virtualenv/venv/conda environment.
modified: completion/available/pip.completion.bash modified: completion/available/pip3.completion.bashpull/1518/head
parent
9fcaab0efc
commit
cd0b2618fb
|
|
@ -2,17 +2,32 @@
|
|||
# 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.
|
||||
|
||||
# For the pyenv-based environment:
|
||||
if which pyenv >/dev/null; then
|
||||
if pyenv which pip 2>/dev/null; then
|
||||
eval "$(pip completion --bash)"
|
||||
fi
|
||||
else
|
||||
if command -v pip >/dev/null; then
|
||||
eval "$(pip completion --bash)"
|
||||
# If the pip package is installed within virtual environments,
|
||||
# you should first install pip for the corresponding environment.
|
||||
|
||||
# Fix pip completion for running it within/outside of pyenv/virtualenv/venv/conda environment.
|
||||
|
||||
_pip_completion_hook() {
|
||||
local _pip
|
||||
# For pip resides within the pyenv/virtualenv/venv/conda environments:
|
||||
if [ -n "$VIRTUAL_ENV" ] && [ -x "$VIRTUAL_ENV/bin/pip" ]; then
|
||||
_pip="$VIRTUAL_ENV/bin/pip"
|
||||
elif [ -n "$CONDA_PREFIX" ] && [ -x "$CONDA_PREFIX/bin/pip" ]; then
|
||||
_pip="$CONDA_PREFIX/bin/pip"
|
||||
# For pip resides outside of a virtual environment:
|
||||
elif [ -x /usr/bin/pip ]; then
|
||||
_pip=/usr/bin/pip
|
||||
fi
|
||||
if [ -n "$_pip" ]; then
|
||||
eval "$($_pip completion --bash)"
|
||||
fi
|
||||
}
|
||||
|
||||
if ! [[ "$PROMPT_COMMAND" =~ _pip_completion_hook ]]; then
|
||||
PROMPT_COMMAND="_pip_completion_hook;$PROMPT_COMMAND";
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,32 @@
|
|||
# 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)"
|
||||
|
||||
# If the pip package is installed within virtual environments,
|
||||
# you should first install pip for the corresponding environment.
|
||||
|
||||
# Fix pip completion for running it within/outside of pyenv/virtualenv/venv/conda environment.
|
||||
|
||||
_pip_completion_hook() {
|
||||
local _pip
|
||||
# For pip resides within the pyenv/virtualenv/venv/conda environments:
|
||||
if [ -n "$VIRTUAL_ENV" ] && [ -x "$VIRTUAL_ENV/bin/pip3" ]; then
|
||||
_pip="$VIRTUAL_ENV/bin/pip3"
|
||||
elif [ -n "$CONDA_PREFIX" ] && [ -x "$CONDA_PREFIX/bin/pip3" ]; then
|
||||
_pip="$CONDA_PREFIX/bin/pip3"
|
||||
# For pip resides outside of a virtual environment:
|
||||
elif [ -x /usr/bin/pip3 ]; then
|
||||
_pip=/usr/bin/pip3
|
||||
fi
|
||||
if [ -n "$_pip" ]; then
|
||||
eval "$($_pip completion --bash)"
|
||||
fi
|
||||
}
|
||||
|
||||
if ! [[ "$PROMPT_COMMAND" =~ _pip_completion_hook ]]; then
|
||||
PROMPT_COMMAND="_pip_completion_hook;$PROMPT_COMMAND";
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue