Skip to content

Commit 0d70dcf

Browse files
Create conda_auto_env.sh
1 parent 2787818 commit 0d70dcf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

conda_auto_env.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Modified from:
2+
# https://github.com/chdoig/conda-auto-env
3+
4+
# Auto activate conda environments
5+
function conda_auto_env() {
6+
if [ -e "environment.yaml" ]; then
7+
ENV_NAME=$(head -n 1 environment.yaml | cut -f2 -d ' ')
8+
# Check if you are already in the environment
9+
if [[ $CONDA_PREFIX != *$ENV_NAME* ]]; then
10+
# Try to activate environment
11+
source activate $ENV_NAME &>/dev/null
12+
fi
13+
fi
14+
}
15+
16+
export PROMPT_COMMAND="conda_auto_env;$PROMPT_COMMAND"

0 commit comments

Comments
 (0)