Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cod tries to learn commands which already have completions #9

Open
zachriggle opened this issue Feb 14, 2020 · 2 comments
Open

cod tries to learn commands which already have completions #9

zachriggle opened this issue Feb 14, 2020 · 2 comments
Labels

Comments

@zachriggle
Copy link

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
@dim-an
Copy link
Owner

dim-an commented Apr 11, 2020

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

@dim-an
Copy link
Owner

dim-an commented Apr 11, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants