diff --git a/helper_script.sh b/helper_script.sh index 86002940989842b89ee1bceb7280d5cc36601bd1..97e052622ede3b221ddd5ec86e63526ce6701b3c 100644 --- a/helper_script.sh +++ b/helper_script.sh @@ -10,20 +10,20 @@ function cd() { # Check all sections of provided path. - for index in $(echo $cd_string | tr "/" "\n") + for index in $(echo ${cd_string} | tr "/" "\n") do # Check if we've looked at any paths yet. - if [[ "$cd_path" ]] + if [[ "${cd_path}" ]] then # Not first part of path. Simply concat index and prev path info. - cd_path="$cd_path/$index" + cd_path="${cd_path}/${index}" else # First part of path. Check current folder, before anything else. - cd_path="$index" + cd_path="${index}" # Deactivate if backing out and .venv folder exists in current folder. - if [[ "$index" == ".." ]] + if [[ "${index}" == ".." ]] then if [[ -d .venv ]] then @@ -34,25 +34,25 @@ function cd() { # Check if current path equals home folder. If so, assume fresh start and deactivate. - if [[ "/$cd_path" == "$HOME" ]] + if [[ "/${cd_path}" == "${HOME}" ]] then cd_venv_deactivate fi # If backing up, check for .venv in parent folder. - if [[ "$index" == ".." ]] + if [[ "${index}" == ".." ]] then # Check for venv folder. - if [[ -d "$cd_path/.venv" ]] + if [[ -d "${cd_path}/.venv" ]] then cd_venv_deactivate fi else - # Otherwise, check if we're going into a new .venv. - if [[ -d "$cd_path/.venv" ]] + # Otherwise, check if we're going into an environment folder. + if [[ -d "${cd_path}/.venv" ]] then - cd_venv_activate "./$cd_path/.venv" + cd_venv_activate "./${cd_path}/.venv" fi fi @@ -60,7 +60,7 @@ function cd() { # Execute normal cd command. - builtin cd "$cd_string" + builtin cd "${cd_string}" # Check for .venv folder in new directory. @@ -81,10 +81,10 @@ cd_venv_activate() { cd_venv_deactivate # Ensure that folder is a Python environment. - if [[ -f "$1/bin/activate" ]] + if [[ -f "${1}/bin/activate" ]] then # Load environment. - . "$1/bin/activate" + . "${1}/bin/activate" fi } @@ -94,7 +94,7 @@ cd_venv_activate() { ## cd_venv_deactivate() { # Check if environment is currently active. - if [[ -n "$VIRTUAL_ENV" ]] + if [[ -n "${VIRTUAL_ENV}" ]] then deactivate fi