virtualenvwrapper: rewrite init script location code (#8521)

This commit is contained in:
Alastair Rankine 2020-02-07 06:06:06 -05:00 committed by GitHub
parent 77aa1795d2
commit e81782ac3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,55 +1,29 @@
virtualenvwrapper='virtualenvwrapper.sh'
virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh'
if (( $+commands[$virtualenvwrapper_lazy] )); then
function { function {
setopt local_options # search in these locations for the init script:
unsetopt equals for f in $commands[virtualenvwrapper_lazy.sh] \
virtualenvwrapper=${${virtualenvwrapper_lazy}:c} $commands[virtualenvwrapper.sh] \
source ${${virtualenvwrapper_lazy}:c} /usr/share/virtualenvwrapper/virtualenvwrapper{_lazy,}.sh \
[[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs" /usr/local/bin/virtualenvwrapper{_lazy,}.sh \
} /etc/bash_completion.d/virtualenvwrapper \
elif (( $+commands[$virtualenvwrapper] )); then /usr/share/bash-completion/completions/virtualenvwrapper
function { do
setopt local_options if [[ -f $f ]]; then
unsetopt equals source $f
source ${${virtualenvwrapper}:c}
}
elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh"
source "/usr/local/bin/virtualenvwrapper.sh"
}
elif [[ -f "/usr/share/virtualenvwrapper/virtualenvwrapper.sh" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/usr/share/virtualenvwrapper/virtualenvwrapper.sh"
source "/usr/share/virtualenvwrapper/virtualenvwrapper.sh"
}
elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
source "/etc/bash_completion.d/virtualenvwrapper"
}
else
print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
"Please install with \`pip install virtualenvwrapper\`" >&2
return return
fi fi
done
print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh.\n"\
"Please install with \`pip install virtualenvwrapper\`" >&2
}
if ! type workon &>/dev/null; then if ! type workon &>/dev/null; then
print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\ print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
"Please check ${virtualenvwrapper}" >&2 "Please check ${virtualenvwrapper}" >&2
return return
fi fi
if [[ "$WORKON_HOME" == "" ]]; then if [[ -z "$WORKON_HOME" ]]; then
print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2 WORKON_HOME="$HOME/.virtualenvs"
return
fi fi
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then