If I type this inside a regular interactive zsh
shell that I have prepared with autoload -U compinit && compinit
:
$ cat --
and then press the Tab key on my keyboard, I get this zsh completion output:
$ cat --
--help -- display help and exit
--number -- number all output lines
--number-nonblank -- number nonempty output lines, overrides -n
--show-all -- equivalent to -vET
--show-ends -- display $ at end of each line
--show-nonprinting -- use ^ and M- notation, except for LFD and TAB
--show-tabs -- display TAB characters as ^I
--squeeze-blank -- suppress repeated empty output lines
--version -- output version information and exit
Q: How can I trigger this output with a regular command via zsh -c ...
?
I tried a few different ways, but so far I have not been able to figure out how to do this. The "natural" approach does not work:
$ zsh -c "autoload -U compinit && compinit && cat --$'\t'"
cat: unrecognized option '-- '
Try 'cat --help' for more information.
Neither does trying to use zle -U
:
$ zsh -c "autoload -U compinit && compinit && zle -U \"cat --$'\t'\""
zsh:zle:1: can only be called from widget function