conda-incubator / conda-zsh-completion

zsh completion for conda
Do What The F*ck You Want To Public License
377 stars 64 forks source link

Improve conda activate suggestions #31

Closed nielstron closed 4 years ago

nielstron commented 4 years ago

1) activate becomes fast by simply parsing a text file 2) activate is now also able to resolve environments without name (specifically those with prefix)

this also resolves #30

nielstron commented 4 years ago

Unfortunately I was not able to find documentation on $HOME/.conda/environments.txt, so I am not sure if this works on every platform

minhduc0711 commented 4 years ago

not working on my side because my environments.txt looks like this

/home/minhduc0711/miniconda3
/home/minhduc0711/miniconda3/envs/asr
/home/minhduc0711/miniconda3/envs/dl-pytorch

However, the proposal in #30 works for me.

nielstron commented 4 years ago

not working on my side because my environments.txt looks like this

Could you please specify your problems? The file on your system seems very similar to the one on my system. Note that on your setup i.e. conda activate as should be auto-completed to conda activate /home/minhduc0711/miniconda3/envs/asr which works too.

In comparison to the approach in #30 the base env is missing in my approach. However this can be fixed by adding a echo base &&, which can (and should) be easily fixed.

nielstron commented 4 years ago

The most recent change covers all cases. On my console:

$ conda activate
base                                      /home/niels/anaconda3/envs/cr36_newccosy
cr36                                      /home/niels/anaconda3/envs/i2dl_ex      
cr36_newccosy                             /home/niels/.test                       
/home/niels/anaconda3                     i2dl_ex                                 
/home/niels/anaconda3/envs/cr36
minhduc0711 commented 4 years ago

@nielstron yeah sorry, I thought the intended behavior was to show environment names only. I see that you have included the idea from #30. It works perfectly as I want now, ty very much :)

esc commented 4 years ago

@nielstron thanks for submitting this. I have a request: could you perhaps make this configurable? In my case this change will flood my terminal with all my unnamed environments, none of which I would like to complete. I appreciate the changes in speed, but this decreases usability for me. If you could make it configurable (and document this option), I would gladly merge this PR!

/Users/esc/git/dask-integration-testing/miniconda3
/Users/esc/git/dask-integration-testing/miniconda3/envs/xarray
/Users/esc/git/numba-integration-testing/miniconda3
/Users/esc/git/numba-integration-testing/miniconda3/envs/fastparquet
/Users/esc/git/texasbbq/miniconda3
/Users/esc/git/texasbbq/miniconda3/envs/pandas
/Users/esc/miniconda3
/Users/esc/miniconda3/envs/anaconda_client
/Users/esc/miniconda3/envs/dgen
/Users/esc/miniconda3/envs/ds_3.8
/Users/esc/miniconda3/envs/llvm-bld
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1592322593242/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1592322827318/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1592325320699/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1592325611974/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1592384015187/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1592384334118/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1594899909668/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1594900301579/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmdev_1594900458459/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmlite_1592322202376/_build_env
/Users/esc/miniconda3/envs/llvm-bld/conda-bld/llvmlite_1592389300926/_build_env
/Users/esc/miniconda3/envs/nltk
/Users/esc/miniconda3/envs/numba_3.7
/Users/esc/miniconda3/envs/numba_3.8
/Users/esc/miniconda3/envs/numba_3.8_numpy_1.19
/Users/esc/miniconda3/envs/numba_datashader
/Users/esc/miniconda3/envs/numba_llvm10
/Users/esc/miniconda3/envs/numba_pandas
/Users/esc/miniconda3/envs/numba_weekly_meeting
/Users/esc/miniconda3/envs/taichi
/Users/esc/miniconda3/envs/test_n117_nb046
/Users/esc/miniconda3/envs/testenv_f0c68fd0-52b9-4532-abf3-92c961662ea4
anaconda_client
base
dgen
ds_3.8
llvm-bld
nltk
numba_3.7
numba_3.8
numba_3.8_numpy_1.19
numba_datashader
numba_llvm10
numba_pandas
numba_weekly_meeting
taichi
test_n117_nb046
testenv_f0c68fd0-52b9-4532-abf3-92c961662ea4
esc commented 4 years ago

You could also think about using the file reading approach, but filtering the unnamed environments, if that is possible it should become the default.

nielstron commented 4 years ago

I think this is possible. I would simply include an internal variable that can be set to toggle reading the environments file. The only difference to listing conda/env are the unnamed environments and absolute paths (the latter of which are rather useless)

esc commented 4 years ago

@nielstron that sounds good, there are several configuration options available for this completion already. Probably best to make another one along the same lines.

nielstron commented 4 years ago

I tested the most recent push on my own machine but you might want to have a look at it yourself

esc commented 4 years ago

@nielstron I tested on my machine and it works for (and is a lot quicker). I appreciate the changes so thank you very much for your contribution!

esc commented 4 years ago

https://github.com/esc/conda-zsh-completion/tree/v0.9 <--- new version, out now.