cod tries to learn commands which already have completions
zachriggle opened this issue · 2 comments
zsh
already ships with lots of completion scripts.
cod
attempts to learn these, even though they already exist.
For example:
$ git add --help
...
┌──> /usr/local/bin/git add --help
└─── cod: learn this command? [yn?] >
cod
should probably check zstyle
or compdef
to determine which autocompletions are already available.
$ zstyle | grep 'completion.*:git'
:completion:*:*:git:* common-commands
It would be nice feature to have but unfortunately it's not that easy to implement.
For now you can use https://github.com/dim-an/cod#configuration. Please check out example configration. You can set up rules to ignore binaries in some paths.
Example of config rule to make cod
ignore binaries from /usr/bin/*
:
[[rule]]
executable = "/usr/bin/*"
policy = 'ignore'
You can still learn ignored binaries using cod learn -- some-binary --help
Regarding why I think this feature is not easy.
When I researched how completion is implemented in bash
I found out that most of them are loaded lazily, i.e. at the start of the session compdef
doesn't show that it knows anything about git
. But when you try to complete git command, bash_completion
package looks for corresponding completion and loads it.
I didn't looked at zsh, but looks like something similar happens here. Output of zstyle | grep git
is empty for me although git
have some completions.