On Mon, Feb 16, 2015 at 3:04 PM, Valentin Haenel <
vale...@haenel.co> wrote:
> Hi Aaron,
>
> * Aaron Meurer <
aaron....@continuum.io> [2015-02-16]:
>> Not to be outdone, I have added support for most of this to conda
>> itself bash with argcomplete (see
>>
http://conda.pydata.org/docs/config.html#tab-completion). I couldn't
>> add the version completion because of an issue with argcomplete
>> (
https://github.com/kislyuk/argcomplete/issues/94). Completion of
>> package names, environment names, and channel names for bash
>> (argcomplete) will be in the next version of conda.
>
> Thanks for you work on this, having good tab-completion is essential
> when using UNIX tools in the 21st century! I just looked at the current
> master of conda and it seems to work well. Two nitpicks I discovered
> while manually fuzzing the implementation.
>
> $ conda install -c <TAB>
>
> Doesn't seem to offer configured channels?
I'm sorry I said channel names above. That was me misremembering. It
isn't supported.
Listing the configured channels isn't very helpful. They are already
included. Adding a configured channel with -c is redundant (unless you
are reordering your channels at the command line, which isn't very
common).
What you'd really want is to complete the channels from binstar, but I
don't know a non-slow way to do this.
>
> $ conda config --remove <TAB>
>
> Should include list configuration keys?
conda config --remove is something that barely works (i.e., you have
to use --force with it, and if you do use it, you'll have to use
--force with every conda config command thereafter). Hence, I have
only minimally supported it, until I can make it work better.
>
> I must confess, that I haven't implemented context sensitivity for the
> -c,--channel option, because I wasn't sure how this is best done.
> After some more deliberation, I figure that only 'install' should be aware
> of it? Like:
>
> $ conda install -c esc --override-channels <TAB>
>
> You could do it for update too, but then the list of offered packages
> should be the intersection between those already installed in the
> environment -- potentially specified by -n or similar -- and those
> available from the channel specified.
Right, there are two sets of package to complete. For install, you
want to list all packages from the channels (taking into account flags
like -c). For update and remove, you want to list only those packages
that are in the environment (taking into account -n and -p).
>
> Should only complete packages from the 'esc' channel on binstar (or
> whereever the default is pointing).
>
> Also, I initially tried to build support for more advanced package
> specs, e.g. <= and >= and so on, but wasn't sure if conda even supported
> this. Even if it did, one would have to auto-quote or auto-escape
> certain characters that would otherwise be interpreted by the shell.
> E.g. > < for redirection. And that would probably be very, very messy.
> So I decided that just supporting '=' is a good trade-off.
It does support them, but you have to quote them on the command line,
like conda install 'python<3'. I'm assuming that works the same in zsh
as bash anyway.
Anyway, I'm pretty happy with the state of tab completion for conda
now that we can complete packages and environment names. The next
thing I would want to see is to extend completion to conda build and
conda env (see
https://github.com/kislyuk/argcomplete/issues/76).
>
>> I still contend that someone should add zsh support to argcomplete,
>> and then both will get improvements automatically.
>
> Yes, DRYing the code up would be quite beneficial. Having to copy and
> paste strings etc.. across is really not that great style. Then again,
> having to do two very similar tasks in fairly different languages does
> allow us to compare notes.
Two advantages of argcomplete:
- We can reuse some of the complicated logic inside of conda for
context sensitive completions (like the logic used to complete package
names when -c, --override-channels, --use-local, etc. are used).
- New flags are added to the completer automatically.
>
>> In the meantime, I'll add a link to this to the conda tab completion
>> docs.
>
> Please do!
It's been done.
http://conda.pydata.org/docs/config.html#tab-completion
Aaron Meurer
>
> V-