Last active
February 17, 2023 06:25
-
-
Save jurihock/8e81013facefca79c666b19c22e0ae00 to your computer and use it in GitHub Desktop.
Miniconda activation script
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
#!/bin/bash | |
# directory containing multiple miniconda installations | |
MINICONDA=~/Miniconda | |
# turn off case sensitivity | |
casematch=$(shopt -p nocasematch) | |
shopt -s nocasematch | |
# search for matching subfolder inside miniconda directory | |
for path in $(ls -d ${MINICONDA}/*); do | |
name=$(basename ${path}) | |
if [[ "${name}" == "${@}" ]]; then | |
miniconda=${path} | |
fi | |
done | |
# restore case sensitivity | |
${casematch} | |
# list all subfolders inside miniconda directory | |
# if previously no matching subfolder found | |
if [[ -z ${miniconda} ]]; then | |
ls -1 ${MINICONDA}; exit | |
fi | |
# activate miniconda via old syntax | |
# source ${miniconda}/bin/activate ${miniconda} | |
# activate miniconda via new syntax | |
eval "$(${miniconda}/bin/conda shell.$(basename ${SHELL}) hook)" | |
# dump info and enter interactive mode | |
conda info; ${SHELL} -i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment