Skip to content

Instantly share code, notes, and snippets.

@jurihock
Last active February 17, 2023 06:25
Show Gist options
  • Save jurihock/8e81013facefca79c666b19c22e0ae00 to your computer and use it in GitHub Desktop.
Save jurihock/8e81013facefca79c666b19c22e0ae00 to your computer and use it in GitHub Desktop.
Miniconda activation script
#!/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