# protect-conda-base.sh # # If you use Anaconda, it is really easy to accidentally install packages # into the base environment. Head that off at the pass. # However, allow installs in a pip virtual environment. # # Allow for an override if you run these commands with a CONDA_PROMPT_OVERRIDE variable set, # as in: # # CONDA_PROMPT_OVERRIDE pip install powerline-shell # # Include this in your .bashrc or .zshrc # # Thanks https://stackoverflow.com/a/69617319/424301 function pip(){ if [ -z "${CONDA_PROMPT_OVERRIDE}" ] && [ -z "${VIRTUAL_ENV}" ] && [ "${CONDA_PROMPT_MODIFIER-}" = "(base) " ] && [ "$1" = "install" ]; then echo "Not allowed in base" else command pip "$@" fi } function extended_conda(){ if [ -z "${CONDA_PROMPT_OVERRIDE}" ] && [ "${CONDA_PROMPT_MODIFIER-}" = "(base) " ] && [ "$1" = "install" ]; then echo "Not allowed in base" else conda "$@" fi } alias conda=extended_conda