run_conda.sh 416 B

1234567891011121314151617
  1. #!/bin/bash
  2. if [ $# -lt 2 ]; then
  3. echo "This script is meant to run a command within a python environment"
  4. echo "It needs at least 2 parameters."
  5. echo "The first one must be the environment name."
  6. echo "The rest will be the command"
  7. exit 255
  8. fi
  9. eval "$(conda shell.bash hook)"
  10. env_name=$1
  11. echo "Activating ${env_name}"
  12. conda activate "$1"
  13. shift 1
  14. echo "Running ${*} in virtual environment"
  15. "$@"