Created
December 7, 2020 03:24
-
-
Save hantoine/fcdcdc891173761b05e40fcec8e27caf to your computer and use it in GitHub Desktop.
Automatically activate a conda environment when entering a directory
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
# The following lines should be added to the file ~/.bashrc | |
# When the current working directory contains a file named .conda-auto-env, the | |
# conda environement whose name is the content of the file will be activated | |
conda-auto-env() { | |
if [ -e ".conda-auto-env" ] ; then | |
env=$(cat .conda-auto-env) | |
if [ "$CONDA_DEFAULT_ENV" != "$env" ] ; then | |
conda activate $env | |
fi | |
fi | |
} | |
export PROMPT_COMMAND="conda-auto-env;$PROMPT_COMMAND" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment