diff --git a/helper_script.sh b/helper_script.sh index d538588702beb93c57c1887763a0a9d2fa19d529..86002940989842b89ee1bceb7280d5cc36601bd1 100644 --- a/helper_script.sh +++ b/helper_script.sh @@ -1,11 +1,9 @@ ### - # Modified "cd" command to automatically load/unload Python ".venv" environments. + # Modified "cd" command to automatically load/unload local Python ".venv" environments. # :$1: The standard path to pass into the "cd" command. ## function cd() { - - # Check if .venv folder exists in path to final location. local cd_string=$@ local cd_path="" local checked_current=false @@ -82,8 +80,12 @@ cd_venv_activate() { # First make sure no other environment is loaded. cd_venv_deactivate - # Load environment. - . "$1/bin/activate" + # Ensure that folder is a Python environment. + if [[ -f "$1/bin/activate" ]] + then + # Load environment. + . "$1/bin/activate" + fi }