add brute-force python env activator function
This commit is contained in:
parent
ceb4701ad4
commit
172abf3410
1 changed files with 28 additions and 0 deletions
|
@ -21,3 +21,31 @@ fi
|
||||||
# <<< conda initialize <<<
|
# <<< conda initialize <<<
|
||||||
|
|
||||||
! is-tty && [ -d "$HOME/mambaforge/envs/dev" ] && conda activate dev
|
! is-tty && [ -d "$HOME/mambaforge/envs/dev" ] && conda activate dev
|
||||||
|
|
||||||
|
snake() {
|
||||||
|
if [[ $1 == "no" ]]; then
|
||||||
|
if [[ $VIRTUAL_ENV != "" ]]; then
|
||||||
|
echo "deactivate python virtualenv: $VIRTUAL_ENV"
|
||||||
|
deactivate
|
||||||
|
elif [[ $CONDA_DEFAULT_ENV != "" ]]; then
|
||||||
|
echo "deactivating conda env: $CONDA_DEFAULT_ENV"
|
||||||
|
conda deactivate
|
||||||
|
else
|
||||||
|
echo 'no environment to leave'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -d $(pwd)/env ]]; then
|
||||||
|
printf 'activating project-specific env: %s\n' "${PWD##*/}/env"
|
||||||
|
conda activate ./env
|
||||||
|
elif [[ -d $(pwd)/venv ]]; then
|
||||||
|
echo "activating python virtualenv"
|
||||||
|
source ./venv/bin/activate
|
||||||
|
elif [[ -d $(pwd)/.venv ]]; then
|
||||||
|
echo "activating python virtualenv"
|
||||||
|
source ./.venv/bin/activate
|
||||||
|
else
|
||||||
|
echo "is there an environment to activate?"
|
||||||
|
echo "I was expecting either a conda(env) or virtualenv(venv,.venv)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue