From 3f36103e1ac5a8e5e5131c4d63572dbf35a627a4 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Thu, 24 Oct 2024 11:36:44 +0200 Subject: [PATCH] (env) no need to switch when same env or no prev env --- setup/tue-env.bash | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup/tue-env.bash b/setup/tue-env.bash index 3f0ac7823..11c41b112 100644 --- a/setup/tue-env.bash +++ b/setup/tue-env.bash @@ -295,7 +295,16 @@ Environment directory '${tue_env_dir}' didn't exist (anymore)""" [[ "${persistent}" == "true" ]] && tue-env set-default "${tue_env}" - _tue-env-deactivate-current-env || { echo "[tue-env](switch) Failed to deactivate the current environment, don't use this terminal anymore, open a new terminal"; return 1; } + if [[ -n "${TUE_ENV}" ]] + then + if [[ "${TUE_ENV}" == "${tue_env}" ]] + then + echo "[tue-env](switch) Already in the '${tue_env}' environment" + return 0 + fi + echo "[tue-env](switch) Deactivating the current environment '${TUE_ENV}'" + _tue-env-deactivate-current-env || { echo "[tue-env](switch) Failed to deactivate the current environment, don't use this terminal anymore, open a new terminal"; return 1; } + fi # Successful, so we can set the environment variables TUE_ENV=${tue_env}