From 951cf819a656ecc9c0111e5d33f0ffdf97c74b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Thu, 2 Jul 2020 17:15:31 +0200 Subject: [PATCH 1/4] Improve conda activate 1) activate becomes fast by simply parsing a text file 2) activate is now also able to resolve environment without name (specifically those with prefix) --- _conda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_conda b/_conda index e840581..16ba637 100644 --- a/_conda +++ b/_conda @@ -128,7 +128,7 @@ local -A opt_args __conda_envs(){ local -a envs - envs=($( conda info -e | sed "1,2d" | cut -f1 -d' ')) + envs=($( cat $HOME/.conda/environments.txt | cut -f1 -d' ')) _describe -t envs 'conda environments' envs } From 1a27527794c526d48c3c1e706bdff9cb1b6e0882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Thu, 16 Jul 2020 12:35:24 +0200 Subject: [PATCH 2/4] Include the base environment in auto-completion --- _conda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_conda b/_conda index 16ba637..4ed260e 100644 --- a/_conda +++ b/_conda @@ -128,7 +128,7 @@ local -A opt_args __conda_envs(){ local -a envs - envs=($( cat $HOME/.conda/environments.txt | cut -f1 -d' ')) + envs=($(echo base && cat $HOME/.conda/environments.txt | cut -f1 -d' ')) _describe -t envs 'conda environments' envs } From a19d4a4ef4f9d6324ae9d1aefa8ccfb6bc0f028a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Thu, 16 Jul 2020 12:45:29 +0200 Subject: [PATCH 3/4] Also include the content of the default prefix dir without path --- _conda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_conda b/_conda index 4ed260e..7588723 100644 --- a/_conda +++ b/_conda @@ -128,7 +128,7 @@ local -A opt_args __conda_envs(){ local -a envs - envs=($(echo base && cat $HOME/.conda/environments.txt | cut -f1 -d' ')) + envs=($(echo base && ls -1 ${${CONDA_EXE}%bin/conda}/envs && cat ${HOME:?}/.conda/environments.txt | cut -f1 -d' ')) _describe -t envs 'conda environments' envs } From 9b3e1bd875aa2dd7f0bae857c2fdc9ad80511b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Sat, 18 Jul 2020 12:06:48 +0200 Subject: [PATCH 4/4] Add configurability of unnamed envs --- _conda | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/_conda b/_conda index 7588723..475fd81 100644 --- a/_conda +++ b/_conda @@ -44,6 +44,11 @@ # # zstyle ":conda_zsh_completion:*" use-groups true # +# To display unnamed environments and prefixes of environments, add the following +# to your '.zshrc': +# +# zstyle ":conda_zsh_completion:*" show-unnamed true +# # To forcefully clean the completion cache, look in '~/.zcompcache' and remove # file starting with 'conda_'. And/or do 'rm ~/.zcompdump*'. # @@ -128,7 +133,9 @@ local -A opt_args __conda_envs(){ local -a envs - envs=($(echo base && ls -1 ${${CONDA_EXE}%bin/conda}/envs && cat ${HOME:?}/.conda/environments.txt | cut -f1 -d' ')) + # only parse environments.txt (including unnamed envs) if asked by the user + zstyle -s ":conda_zsh_completion:*" show-unnamed tmp + envs=($(echo base && ls -1 ${${CONDA_EXE}%bin/conda}/envs && (test -n "$tmp" && cat ${HOME:?}/.conda/environments.txt) | cut -f1 -d' ')) _describe -t envs 'conda environments' envs }