From a462c5ae7aadd23acddb6f0d928a0c99ace115e0 Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Sat, 31 Oct 2020 18:14:35 -0400 Subject: [PATCH] Clean up syntax of helper script --- helper_script.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/helper_script.sh b/helper_script.sh index 8600294..97e0526 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 -- GitLab