Skip to content

Instantly share code, notes, and snippets.

@OAkyildiz
Created March 26, 2018 19:02
Show Gist options
  • Save OAkyildiz/bb70418a3cbabbbd2a13138901921f30 to your computer and use it in GitHub Desktop.
Save OAkyildiz/bb70418a3cbabbbd2a13138901921f30 to your computer and use it in GitHub Desktop.
Enable conda, add it to the path, optionally activate an environment and remove other packages from PYTHONPATH or vice-versa
#! /bin/bash
if [ "$CONDA" == true ] ; then
if ! [ -z $CONDA_DEFAULT_ENV ] && ! [ "$CONDA_DEFAULT_ENV" == "root" ] ; then
echo "Deactivating ${CONDA_DEFAULT_ENV} first"
source deactivate
fi
export PATH=$NOCONDA_PATH
export PYTHONPATH=$ROS_PYTHON:$PYTHONPATH
export CONDA=false
echo -e "\e[38;5;82mConda down! \e[0m"
else
export NOCONDA_PATH=$PATH
export PATH=/opt/anaconda3/bin:$PATH
export CONDA=true
echo -e "\e[38;5;82mSnakes on the plane! \e[0m"
if [ -z $2 ]; then
export ROS_PYTHON_PKGS=$PYTHONPATH
unset PYTHONPATH
fi
if ! [ -z $1 ]; then
echo "activating ${1}"
source activate $1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment