devour is just a prefix for other commands and doesn't take any options at all for itself, use the
_precommand completion function. This is what zsh uses for
compdef _precommand devour
If the prefix command has options, the usual way to specify how to complete these options is the
_arguments function. Pass at least
-S -A "-*" to
_arguments to indicate that no option to the prefix must be completed after the command name, and that
-- can appear before the command name (which allows the command name to start with a dash). To specify that only external commands (and not aliases, functions or builtins) can be command names, specify that the completion for the first argument (
_command_names -e. Supply a completion for the other non-option arguments (
*) that dispatches to
_normal -p $service. Note that
_arguments does some very complex parsing, and punctuation and whitespace are significant in places where you might
not expect it to be. (The effect of getting it wrong can range from not getting completions at all, to very minor issues like menu completion not displaying expected hints or completing the wrong thing in certain specific nested contexts.) If in doubt, copy from the snippet below or from a completion function that ships with zsh.
_arguments -S -A '-*' : \
'1:command: _command_names -e' '*:: : _normal -p $service'
_setsid are some nice, simple examples. Some more elaborate examples include
See Dynamic zsh autocomplete for custom commands for generic advice on how and where to put the completion function.
Note that this answer assumes that you're using the “new-style” (added mid-1990s) completion system, with
compinit in your