From bf50ae88e20f0941e569db98fd56124cbc5d2959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Mon, 10 Oct 2022 19:49:32 +0200 Subject: [PATCH] List environments in CONDA_ENVS_PATHS and CONDA_ENVS_DIRS --- _conda | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/_conda b/_conda index 4bc7fae..372163d 100644 --- a/_conda +++ b/_conda @@ -156,6 +156,7 @@ __conda_envs(){ local -a envs unnamed sort globalfirst localenvs globalenvs local -a ls_opts=("-1") local -a describe_opts + local localenvspath # only parse environments.txt (including unnamed envs) if asked by the user zstyle -s ":conda_zsh_completion:*" show-unnamed unnamed zstyle -s ":conda_zsh_completion:*" sort-envs-by-time sort @@ -170,7 +171,14 @@ __conda_envs(){ globalenvs+=("base") # local envs (if exists). - localenvs=($([[ -d "${HOME:?}/.conda/envs" ]] && ls $ls_opts ${HOME:?}/.conda/envs)) + if [[ -n $CONDA_ENVS_PATH ]]; then + localenvspath=$CONDA_ENVS_PATH + elif [[ -n $CONDA_ENVS_DIRS ]]; then + localenvspath=$CONDA_ENVS_DIRS + else + localenvspath=${HOME:?}/.conda/envs + fi + localenvs=($([[ -d $localenvspath ]] && ls $ls_opts $localenvspath)) if test -n "$globalfirst"; then envs=($globalenvs $localenvs) @@ -180,7 +188,7 @@ __conda_envs(){ # unmaned envs (if show-unammed). if test -n "$unnamed"; then - envs+=($( (test -n "$unnamed" && cat ${HOME:?}/.conda/environments.txt) | cut -f1 -d' ' | sed -e "s|^${HOME:?}/.conda/envs/||")) + envs+=($( (test -n "$unnamed" && cat ${HOME:?}/.conda/environments.txt) | cut -f1 -d' ' | sed -e "s|^$localenvspath/||")) fi _describe $describe_opts -t envs 'conda environments' envs