From 5f108c6d340918229b4620b062b104578ac7e686 Mon Sep 17 00:00:00 2001 From: guger Date: Mon, 15 Apr 2024 13:12:45 +0200 Subject: [PATCH 1/3] Add support for miniconda installations via homebrew --- _conda | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/_conda b/_conda index 733c691..2f2a056 100644 --- a/_conda +++ b/_conda @@ -168,6 +168,7 @@ local -A opt_args __conda_envs(){ local -a envs unnamed sort globalfirst localenvs globalenvs + local -a conda_path local -a ls_opts local -a describe_opts local localenvspath @@ -182,8 +183,16 @@ __conda_envs(){ describe_opts+=("-V") fi + conda_exec=$(which conda) + + if test ${${conda_exec}#*"homebrew"} != ${conda_exec}; then + conda_path="/opt/homebrew/Caskroom/miniconda/base/envs" + else + conda_path="${${CONDA_EXE}%bin/conda}/envs" + fi + # global envs (if exists) and base env. - globalenvs=($([[ -d "${${CONDA_EXE}%bin/conda}/envs" ]] && ls $ls_opts ${${CONDA_EXE}%bin/conda}/envs)) + globalenvs=($([[ -d "${conda_path}" ]] && ls $ls_opts ${conda_path})) globalenvs+=("base") # local envs (if exists). From 918002008455cea64effc28545eec74e54ad0ddd Mon Sep 17 00:00:00 2001 From: Daniel Guger Date: Mon, 15 Apr 2024 15:15:26 +0200 Subject: [PATCH 2/3] Apply suggestions from review Use inherent style in if statements and add comments. Co-authored-by: Emergency Self-Construct --- _conda | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_conda b/_conda index 2f2a056..443f435 100644 --- a/_conda +++ b/_conda @@ -185,7 +185,8 @@ __conda_envs(){ conda_exec=$(which conda) - if test ${${conda_exec}#*"homebrew"} != ${conda_exec}; then +# Detect homebrew installations and set path accordingly. + if [[ ${${conda_exec}#*"homebrew"} != ${conda_exec} ]]; then conda_path="/opt/homebrew/Caskroom/miniconda/base/envs" else conda_path="${${CONDA_EXE}%bin/conda}/envs" From e4b35ef823f72708e6d8e81a6573ae5bb95b5d33 Mon Sep 17 00:00:00 2001 From: Daniel Guger Date: Mon, 15 Apr 2024 15:17:49 +0200 Subject: [PATCH 3/3] Correct comment alignment. --- _conda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_conda b/_conda index 443f435..795d140 100644 --- a/_conda +++ b/_conda @@ -185,7 +185,7 @@ __conda_envs(){ conda_exec=$(which conda) -# Detect homebrew installations and set path accordingly. + # Detect homebrew installations and set path accordingly. if [[ ${${conda_exec}#*"homebrew"} != ${conda_exec} ]]; then conda_path="/opt/homebrew/Caskroom/miniconda/base/envs" else