zsh-users / zsh-completions

Additional completion definitions for Zsh.
Other
6.94k stars 713 forks source link

Is there a place for incomplete completion scripts? #780

Open ScoreUnder opened 3 years ago

ScoreUnder commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.