From df8850515f75dd965a55079b8febe8ff478d2045 Mon Sep 17 00:00:00 2001 From: Gavin Shriver Date: Thu, 5 Sep 2024 12:09:55 -0700 Subject: [PATCH] add zsh-completion example --- examples/zsh-completion | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/zsh-completion diff --git a/examples/zsh-completion b/examples/zsh-completion new file mode 100644 index 0000000..9170092 --- /dev/null +++ b/examples/zsh-completion @@ -0,0 +1,17 @@ +#compdef examples +compdef _examples examples + +_examples() { + local IFS=$'\n' + local -a completions + completions=($(GO_FLAGS_COMPLETION=1 "${words[@]}")) + if [[ -n "$completions" ]]; then + _describe 'command' completions + fi + return 1 +} + +# don't run the completion function when being source-ed or eval-ed +if [ "$funcstack[1]" = "_examples" ]; then + _examples "$@" +fi \ No newline at end of file