I'm trying to make use of zsh's completion widgets in my own scripts. At one point I'd like have access to the result of every completion that is active in zsh, or rather I want to obtain the final result of the completion chain.
function foo() {
do_unrelated_stuff()
# call zsh completion
comp_results=_main_complete_() # won't work like this, can only be called from within a completion function
if [[ "$#comp_results" -gt "0" ]]; then
# do something
echo "results:"
else
# do something else
echo "no results"
fi
}
I already thought of creating a custom completion function that just calls
_main_complete
(or whichever function is appropriate) and stores the results in an exported variable to make it accessible to other functions. However, this would also imply calling the custom completion function somehow - and I don't know how. Is it even possible to get "intermediate" completion results without performing the actual completion?