completion/pip: simplify code flow
Short-circuit the loader rather than indenting nearly the whole file. ALSÖ, assign the `_pip_completion()` handler directly once it's loaded so that we get out of the way once we load it.pull/1964/head
parent
d6c4c0cc88
commit
b897c7d3ce
|
|
@ -6,14 +6,15 @@
|
||||||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||||
# you should first initialize the corresponding environment.
|
# you should first initialize the corresponding environment.
|
||||||
# So that pip is in the system's path.
|
# So that pip is in the system's path.
|
||||||
if _command_exists pip; then
|
_command_exists pip || return
|
||||||
function __bash_it_complete_pip() {
|
|
||||||
|
function __bash_it_complete_pip() {
|
||||||
if _command_exists _pip_completion; then
|
if _command_exists _pip_completion; then
|
||||||
|
complete -o default -F _pip_completion pip
|
||||||
_pip_completion "$@"
|
_pip_completion "$@"
|
||||||
else
|
else
|
||||||
eval "$(pip completion --bash)"
|
eval "$(pip completion --bash)"
|
||||||
_pip_completion "$@"
|
_pip_completion "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
complete -o default -F __bash_it_complete_pip pip
|
complete -o default -F __bash_it_complete_pip pip
|
||||||
fi
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||||
# you should first initialize the corresponding environment.
|
# you should first initialize the corresponding environment.
|
||||||
# So that pip3 is in the system's path.
|
# So that pip3 is in the system's path.
|
||||||
if _command_exists pip3; then
|
_command_exists pip3 || return
|
||||||
function __bash_it_complete_pip3() {
|
|
||||||
|
function __bash_it_complete_pip3() {
|
||||||
if _command_exists _pip_completion; then
|
if _command_exists _pip_completion; then
|
||||||
|
complete -o default -F _pip_completion pip3
|
||||||
_pip_completion "$@"
|
_pip_completion "$@"
|
||||||
else
|
else
|
||||||
eval "$(pip3 completion --bash)"
|
eval "$(pip3 completion --bash)"
|
||||||
_pip_completion "$@"
|
_pip_completion "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
complete -o default -F __bash_it_complete_pip3 pip3
|
complete -o default -F __bash_it_complete_pip3 pip3
|
||||||
fi
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue