Last active
June 5, 2017 15:48
-
-
Save harryscholes/4e38c46f7d713bd70cd18960577adcf8 to your computer and use it in GitHub Desktop.
Anaconda autoenv that won't reactivate the environment when changing into child directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dependencies: conda, autoenv | |
# cd into dir containing environment.yml file and run: conda env create | |
# save this gist to file named .env in the dir | |
# run: source /usr/local/opt/autoenv/activate.sh | |
# set to the name of the Anaconda environment contained in environment.yml | |
venv= | |
# get the current environment | |
currentvenv="" | |
if [[ $CONDA_DEFAULT_ENV != "" ]] | |
then | |
currentvenv=$CONDA_DEFAULT_ENV | |
fi | |
# if required change to project directory environment | |
if [[ "$currentvenv" != "$venv" ]] | |
then | |
echo "source activate $venv" | |
source activate $venv | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by: https://stackoverflow.com/questions/22839934/autoenv-executes-even-in-subfolder