mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-17 04:29:14 +02:00
Add support .venv folder as virtual env
This commit is contained in:
parent
0c0a13f9b9
commit
dd3f92fe97
1 changed files with 50 additions and 52 deletions
|
|
@ -1,10 +1,5 @@
|
|||
virtualenvwrapper='virtualenvwrapper_lazy.sh'
|
||||
if (( $+commands[$virtualenvwrapper] )); then
|
||||
|
||||
if [[ "$WORKON_HOME" == "" ]]; then
|
||||
echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work"
|
||||
else
|
||||
|
||||
source ${${virtualenvwrapper}:c}
|
||||
|
||||
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
|
||||
|
|
@ -22,6 +17,8 @@ if (( $+commands[$virtualenvwrapper] )); then
|
|||
# Check for virtualenv name override
|
||||
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
|
||||
ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
|
||||
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
|
||||
ENV_NAME="$PROJECT_ROOT/.venv"
|
||||
elif [[ "$PROJECT_ROOT" != "." ]]; then
|
||||
ENV_NAME=`basename "$PROJECT_ROOT"`
|
||||
else
|
||||
|
|
@ -32,6 +29,8 @@ if (( $+commands[$virtualenvwrapper] )); then
|
|||
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
|
||||
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
|
||||
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
|
||||
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||
fi
|
||||
fi
|
||||
elif [ $CD_VIRTUAL_ENV ]; then
|
||||
|
|
@ -55,7 +54,6 @@ if (( $+commands[$virtualenvwrapper] )); then
|
|||
set -A chpwd_functions workon_cwd
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`."
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue