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

Is there a place for incomplete completion scripts? #780

Open
ScoreUnder opened this issue Feb 4, 2021 · 2 comments
Open

Is there a place for incomplete completion scripts? #780

ScoreUnder opened this issue Feb 4, 2021 · 2 comments
Labels

Comments

@ScoreUnder
Copy link
Contributor

There are great usability improvements which can be afforded by incomplete completion scripts. A good example is nethogs; if anyone has used this program on more than one machine, they will know the inconvenience of having to scan ip l for the desired interface name rather than just being able to complete it on the command line. Especially in older versions where it did not run without an interface explicitly specified.

Here's an incomplete nethogs completion script to illustrate:

#compdef nethogs
_arguments '*:interface:_net_interfaces'

(This is incredibly trivial but if it needs licensing, e.g if someone suddenly feels the urge to build upon it, as the sole author of that code I release it under the zsh license)

That script obviously does not complete any options, and it is barely even scratching the surface of what nethogs offers, but nonetheless it is a big improvement over zsh's default filename completion. Is there a place for these kinds of incomplete scripts? Another repository with an unofficial blessing perhaps?

@okapia
Copy link
Contributor

okapia commented Feb 4, 2021

You can just do compdef _net_interfaces nethogs in your own .zshrc and I quite often do something like that. The contribution guidelines for this project do state that partially implemented completion functions are not accepted, though I'm not entirely sure exactly why. Zsh itself hasn't always been strict on that in the past but it is important to look for contexts where file completion is applicable and avoid breaking at least those - broken file completion tends to annoy users. Sometimes it is very hard to get the last 1% of completeness working in a completion function. Besides here and zsh proper, the other logical (and arguably the best) place to contribute zsh completions is the upstream project, in this case nethogs. This is an especially good choice for more obscure projects.

@nicoulaj
Copy link
Member

nicoulaj commented May 3, 2021

I added this rule because people would submit inconsistent completions with only a few options implemented, without any comment mentioning it. It is not to be taken literally, just deter bad contributions. In your case completion for arguments is implemented, and completion for options is not, so there is a logic and someone interested in contributing can use this compdef and improve it.

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

3 participants