Don't create venv and .envrc if .envrc already exists.

This is to avoid duplicate PATH in .envrcs.
This commit is contained in:
Julien Palard 2023-01-20 13:38:01 +01:00
parent faee2d9da8
commit 799ab218ad
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
1 changed files with 7 additions and 1 deletions

View File

@ -178,8 +178,14 @@ venv()
# direnv-enabled venv creation.
if ! [[ -d .venv ]]
then
if [[ -f .envrc ]]
then
echo '`.venv` does not exists but `.envrc` file already exists!'
echo "Human? Untangle it, please."
return
fi
"python$1" -m venv .venv
echo 'PATH=$(pwd)/.venv/bin/:$PATH' >> .envrc
echo 'PATH=$(pwd)/.venv/bin/:$PATH' > .envrc
fi
}