Alon Bar-Lev <alo...@gentoo.org> wrote:
>
> I do not want to write completion for every command out there.

For most commands there already do exist completion functions.
Essentially, it is only your own scripts for which you have
to do it, and this does not take a lot of time when you write
the scripts anyway...
In my case, I had to write 11 files (not counting
the projects which I had made public for which I wrote
completions files, of course, as well).
It is a surprisingly low number of commands which one really
uses, and the time spent to write a completion was always
worth it, in the end...

> I did not press tab and it completes...

This can happen only if you are using something like auto-fu-zsh.
The latter is very convenient, but only if you have
"perfect" completion functions for everything.
Otherwise it can be very annoying.

>> Usually there is no point to specify this globally.
>
> yes there is, most commands that have no specific completion will
> enjoy --xxx=<TAB> to complete a file name.

Don't do it (trying to enable "correct" completion for
commands without completion files) - it will fail anyway:
There is no "generic" completion which is always right.

You might try to write some "generic" completion functions
and assign them to a whole bulk of your commands, but in my
experience you are bettter off to spend the time to write
correct completions in the first place.

> how? can you give an example?

/usr/share/zsh/site-functions/_enjoy:

#compdef enjoy
_arguments : \
'--file=[use specified file for output]:output file:_files' \
'*:files:_files'


Reply via email to