Coder Social home page Coder Social logo

conda-zsh-completion's People

Contributors

antony-frolov avatar apjanke avatar chuyj avatar coldfix avatar dstansby avatar esc avatar huitzilo avatar hwalinga avatar jezdez avatar jnooree avatar johannes-mueller avatar levbishop avatar m-novikov avatar nielstron avatar nitlev avatar olegtarasov avatar rmekdma avatar taylorkangbeck avatar vmiheer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

conda-zsh-completion's Issues

how to install?

Please add installation instruction

I read _conda file but don't understand!

conda activate completion

Issue

conda activate does not complete existing named envs other then base.

(base) > $  # Pressing `tab` after `conda activate` with _no_ prefix yields --
(base) > $ conda activate base base base base base base base base base # etc. 

(base) > $ # Pressing `tab` after `conda activate` with _something_ prefix yields --
(base) > $ conda activate something_main_complete:202: permission denied:
_main_complete:202: permission denied:
_main_complete:202: permission denied:


(base) > $ conda env list  # other envs exist
# conda environments:
#
ishow-oxip                        /homes/harelw/.conda/envs/ishow-oxip
py3.7-mx-build                 /homes/harelw/.conda/envs/py3.7-mx-build
py3.7-opencv                    /homes/harelw/.conda/envs/py3.7-opencv
py3.7-oxip-mx-test           /homes/harelw/.conda/envs/py3.7-oxip-mx-test
py3.7-oxucicd-mx-dev      /homes/harelw/.conda/envs/py3.7-oxucicd-mx-dev
base                              *   /usr/local/conda

(base) > $ cat  ~/.conda/environments.txt  # also here, for completeness 
/homes/harelw/.conda/envs/py3.7-oxip-mx-test
/homes/harelw/.conda/envs/ishow-oxip
/homes/harelw/.conda/envs/py3.7-mx-build
/homes/harelw/.conda/envs/py3.7-oxucicd-mx-dev
/homes/harelw/.conda/envs/py3.7-opencv


(base) > $ # other compeltions work
(base) > $ conda env # pressed tab
create  -- Create an environment based on an environment file
export  -- Export a given environment
list    -- List the Conda environments
remove  -- Remove an environment
update  -- Update the current environment based on environment file

Environment and Installation Details

  • Using oh-my-zsh ,
  • Plugin installed according to instructions in _conda:
    git clone https://github.com/esc/conda-zsh-completion ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/conda-zsh-completion
  • Plugin added to ~/.zshrc
  • Tried with both autoload after / before source $ZSH/oh-my-zsh.sh
  • conda version 4.8.2
    • miniconda installation
  • os ubuntu 18.04

Many thanks,
Harel

How about a LICENSE file?

I know you declare the license in the _conda source, but how about adding a LICENSE file to make it easier for users to find, and so GitHub can automatically detect it and label your repo as so licensed?

Clarity for implementing for oh-my-zsh users

# And add lines in `.zshrc`

It may be my thick skull, but I found this bit confusing. For clarity, if you are using oh-my-zsh then your implementation (assuming your oh-my-zsh is blank slate) should look like this:

# ~/.zshrc

# Add the plug in next to git.
plugins=(git conda-zsh-completion)

# Don't change this line.
source $ZSH/oh-my-zsh.sh

# Auto load after sourcing oh-my-zsh.sh.
autoload -U compinit && compinit

Bad alignment

I am seeing bad alignment in my conda completions when using menu selection. I really have no idea how this works though, so I'm not sure if this is the completion's fault or zsh.

I am using zsh v5.3.1 on macOS 10.13 beta:

% zsh --version
zsh 5.3.1 (x86_64-apple-darwin17.0.0)

The relevant section of my zshrc:

# Completion
#--------------------
autoload -Uz compinit && compinit -u

zstyle ':completion:*' use-cache true # Cache completion to `${ZDOTDIR}/.zcompcache`
zstyle ':completion:*' squeeze-slashes true # Strip slashes from directories
zstyle ':completion:*' menu select # Make the menu interactive with arrow keys

bindkey '^I' menu-expand-or-complete
bindkey '^[[Z' reverse-menu-complete

The results I am seeing:

% conda build
build  -- tool for building conda packages
bundle   -- Create or extract a "bundle package" (EXPERIMENTAL)
clean   -- Remove unused packages and caches.
config  -- Modify configuration values in .condarc.
create     -- Create a new conda environment from a list of specified packages.
env    -- Manage environments.
help  -- Displays a list of available conda commands and their help strings.
info       -- Display information about current conda install.
init     -- Initialize conda into a regular environment. (DEPRECATED)
install  -- Install a list of packages into a specified conda environment.
list       -- List linked packages in a conda environment.
package  -- Low-level conda package utility. (EXPERIMENTAL)
remove     -- Remove a list of packages from a specified conda environment.
run      -- Launches an application installed with Conda.
search   -- Search for packages and display their information.
uninstall  -- Alias for conda remove
update  -- Update conda packages.

_conda

parse error near `^M'

I went through all the steps and when I try to do autocompletion, all I get are 3 dots and nothing else. A quick error does flash and disappear, but it says that there was a parse error on line 417 of _conda. Of course this may change with updates, so here is what that offending line is on my side:

image

FWIW:

  1. I have been using zsh for years and never had an issue
  2. I'm using WSL running ubuntu 20

'Conda activate' always completes with all environment variables

Great zsh completion when using zsh & conda.

Just a little problem: when i tried to complete 'conda activate', it will always show all my environment variables before my conda env list. Something like:

image

My system is CentOS 7.9.2009, and I use oh-my-zsh. I have done following steps to install:

git clone https://github.com/esc/conda-zsh-completion ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/conda-zsh-completion

(add to .zshrc)
plugins=(… conda-zsh-completion)
autoload -U compinit && compinit

Error when mistype subcommand

conda aa<TAB> should return an error since no subcommand started with aa, but it comes a weird error and ruins the $PROMT.

$ conda aa<TAB>
$ conda aa_main_complete:202: permission denied:
_main_complete:202: permission denied:
conda       conda aa
No matches for: `conda commands'

`autoload -U compinit && compinit` has no effect unless put in the end of the file

I am using oh-my-zsh in a Mac. For me, the way I found to make the plugin work was doing the following in the .zshrc file:

  1. clone the repository on the oh-my-zsh plugin repository
git clone https://github.com/esc/conda-zsh-completion ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/conda-zsh-completion
  1. Adding the conda-zsh-completion on the list of plugins
plugins=(git conda-zsh-completion) # this was, by default, plugins=(git)
  1. Adding the following line in the *end of the file, below the line *source $ZSH/oh-my-zsh.sh:
autoload -U compinit && compinit 

This was slightly different than (what I understood) the instructions said.
The difference is that I purposely put the step 3 line after the sourcing of oh-my-zsh.sh.
If I put step 3 line just below step 2 line it does not work (possibly the command gets overwriten in oh-my-zsh.sh...).


I wonder why this happened in my machine and if my case is the rule or the exception.

In case it happens to at least some people, do you think it is worth adapting the readme to specifying the step 3 should be after source $ZSH/oh-my-zsh.sh?

thanks

Crashes when trying to complete `conda create --clone`

When trying to complete a command in conda create ..., the whole completion crashes with __conda_package_available:5: command not found: python.

Then, zsh doesn't respond anymore. When using a KeyboardInterrupt, this error is shown:

--- Logging error ---
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/core/subdir_data.py", line 165, in query_all
result = tuple(
^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/concurrent/futures/_base.py", line 619, in result_iterator
yield _result_or_cancel(fs.pop())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/concurrent/futures/_base.py", line 317, in _result_or_cancel
return fut.result(timeout)
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/concurrent/futures/_base.py", line 451, in result
self._condition.wait(timeout)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/threading.py", line 327, in wait
waiter.acquire()
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/exception_handler.py", line 17, in call
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/cli/main.py", line 83, in main_subshell
exit_code = do_call(args, parser)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/cli/conda_argparse.py", line 164, in do_call
result = getattr(module, func_name)(args, parser)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/cli/main_search.py", line 92, in execute
SubdirData.query_all(spec, channel_urls, subdirs),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/core/subdir_data.py", line 164, in query_all
with Executor() as executor:
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/concurrent/futures/_base.py", line 647, in exit
self.shutdown(wait=True)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/concurrent/futures/thread.py", line 235, in shutdown
t.join()
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/threading.py", line 1119, in join
self._wait_for_tstate_lock()
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/threading.py", line 1139, in _wait_for_tstate_lock
if lock.acquire(block, timeout):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/gateways/logging.py", line 127, in emit
self.flush()
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/logging/init.py", line 1094, in flush
self.stream.flush()
BrokenPipeError: [Errno 32] Broken pipe
Call stack:
File "/opt/homebrew/Caskroom/miniconda/base/bin/conda", line 13, in
sys.exit(main())
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/cli/main.py", line 128, in main
return conda_exception_handler(main, *args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/exception_handler.py", line 388, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/exception_handler.py", line 20, in call
return self.handle_exception(exc_val, exc_tb)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/exception_handler.py", line 71, in handle_exception
self._print_conda_exception(CondaError("KeyboardInterrupt"), _format_exc())
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/exception_handler.py", line 84, in _print_conda_exception
print_conda_exception(exc_val, exc_tb)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/exceptions.py", line 1256, in print_conda_exception
logger.info("%s\n" % exc_json)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/logging/init.py", line 1489, in info
self._log(INFO, msg, args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/logging/init.py", line 1634, in _log
self.handle(record)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/logging/init.py", line 1644, in handle
self.callHandlers(record)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/logging/init.py", line 1706, in callHandlers
hdlr.handle(record)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/logging/init.py", line 978, in handle
self.emit(record)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/conda/gateways/logging.py", line 132, in emit
self.handleError(record)
Message: '{\n "caused_by": "None",\n "error": "CondaError: KeyboardInterrupt",\n "exception_name": "CondaError",\n "exception_type": "<class 'conda.CondaError'>",\n "message": "KeyboardInterrupt"\n}\n'
Arguments: ()
Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

When waiting for something to happen, after some minutes it starts printing lots of text, which look like a json formatted list of packages including all metadata but I'm not sure what it is.

Some bugs when completing -h and -V

When type conda - and press tab, my terminal shows these:

$ conda -
--help                                                                                                 
--version                                                                                              
-h                                                                                                     
-V                                                                                                     
-- show this help message and exit                                                                     
-- show programs version number and exit                                                               
--help                                                                                                 
--version                                                                                              
-h                                                                                                     
-V                                                                                                     
-- show this help message and exit                                                                     
-- show programs version number and exit                                                               
--help                                                                                                 
--version                                                                                              
-h                                                                                                     
-V                                                                                                     
-- show this help message and exit                                                                     
-- show programs version number and exit

I uses oh-my-zsh to manage this plugin.

Autocompletion doesn't find conda environments

I've installed miniconda on my Mac with Sonoma 14.4.1.

I'm running zsh v5.9, having oh-my-zsh installed.

Unfortunately, conda-zsh-completetion doesn't find my conda environments for completion, it just always inserts base.

Is there any way I can debug this further?

Adding custom env directory

I noticed that my envs are stored under ~/anaconda3/envs - is there some way to specify it too?

Tasks

No tasks being tracked yet.

source activate autocomplete

I was wondering how hard it would be extend this to support auto-completion for source activate (which would list the available conda environements).?

There is some discussion about it in conda/conda#2595 and conda/conda#822 suggesting that it might be more simply achievable with zsh than bash...

Create a tag for v0.10

Hi,

Thanks for creating this.

Could you please create a tag for the latest version (which I believe includes _mamba - 8 months ago)?
That would allow package managers to create a new version including the latest changes.

Thanks!

Doesn't work like "similar" completion systems

I tried installing the completion via antibody, which loads the plugin into $fpath fine. However, it does not work in my dotfiles due my placement of autoload -U compinit; compinit. For all of my other completion settings (including https://github.com/zsh-users/zsh-completions/), compinit must be run before they are sourced. By contrast, conda-zsh-completion requires that compinit be run after it is sourced. So my .zshrc ends up looking like:

autoload -U compinit; compinit
source /path/to/completion_settings.zsh # includes the zstyle commands for conda-zsh-completion
source /antibody/plugin/source.zsh # includes conda-zsh-completion in $fpath
compinit # only required for conda-zsh-completion

Two primary questions:

  1. Why this completion plugin is different to the others?
  2. Whether this can be changed to match the behavior?

I'm not familiar enough with zsh completions to figure out the answers to either of these unfortunately.

Not working with Prezto

Hi, I'm trying to use this plugin with Prezto but it's not turning on automatically.

All my other Prezto config files are default. Here's the relevant part in my zshrc:

# env suggetions for conda
fpath+=/home/minhduc0711/conda-zsh-completion

# zsh configuration framework
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi

However if I run compinit after starting a new shell then it works again. Any ideas on how to fix this? Thank you.

Multi-user environments cannot completion

user@host$ conda env list
# conda environments:
#
test_conda               /home/public/user/.conda/envs/test_conda
base                  *  /home/public/conda/anaconda3
py36-torch1.4            /home/public/conda/envs/py36-torch1.4
user@host$ pwd
/home/public/user
user@host$ conda activate 
base        test_conda
user@host$ conda activate py

I cannot completion other environment, except the environment created by myself.

Inefficient env list calculation

The current implementation is a bit slow, if you look at it from the perspective of navigating in terminal:
https://github.com/esc/conda-zsh-completion/blob/4121e838c83fb84461b2c1332929ab34a26fbf62/_conda#L131
My benchmark (for 10 runs):

➜ bash -c "time for i in {1..10}; do conda info -e | sed '1,2d' | cut -f1 -d' ' >> /dev/null; done"

real	0m3.070s
user	0m2.467s
sys	0m0.594s

My proposed change:
echo base && ls -1 ${${CONDA_EXE}%bin/conda}/envs && echo
(echo at the end is not required but I wanted both implementations to create exactly the same output)
and benchmark (for 10 runs):

➜ bash -c "time for i in {1..10}; do (echo base && ls -1 ${${CONDA_EXE}%bin/conda}/envs && echo) >> /dev/null; done"

real	0m0.039s
user	0m0.013s
sys	0m0.021s

I've been using this replacement for over a year now for conda activate and I didn't have any issues.

I can create a PR if you think this change is reasonable.`

Documentation / HowTo?

I am not super familiar with shell, which is why a documentation / step by step howto or examples for different use cases, would be really appreciated

conda create fails on macOS

Removing conda-zsh-completion from .zshrc solves the problem.

~
base ❯ conda env create -n xxx python=3.8

SpecNotFound: Invalid name, try the format: user/package

Installation is not working, any debugging tips?

Tried following instructions but its not working for me

I tried this in my zshrc and also in a current session:

# cloned repo 
fpath+=/path/to/where/you/installed/conda-zsh-completion
compinit
# also tried compinit conda

When I try tab completion it doesnt work. I also see no errors or anything so not sure how to debug this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.