Skip to content

Instantly share code, notes, and snippets.

@harryscholes
Last active June 5, 2017 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryscholes/4e38c46f7d713bd70cd18960577adcf8 to your computer and use it in GitHub Desktop.
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
# 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
@harryscholes
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment