From d234c0b44114354bfd2471aeab7a999e02877ae2 Mon Sep 17 00:00:00 2001 From: autopp Date: Tue, 24 Dec 2019 09:37:17 +0900 Subject: [PATCH] doc: add example code of generating Zsh completion --- zsh_completions.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zsh_completions.md b/zsh_completions.md index df9c2eac9..d21f58c82 100644 --- a/zsh_completions.md +++ b/zsh_completions.md @@ -4,6 +4,14 @@ Cobra supports native Zsh completion generated from the root `cobra.Command`. The generated completion script should be put somewhere in your `$fpath` named `_`. +```go +// Output to given io.Writer +rootCmd.GenZshCompletion(os.Stdout) + +// Output to given file +rootCmd.GenZshCompletionFile("/path/to/fpath/_your_command") +``` + ### What's Supported * Completion for all non-hidden subcommands using their `.Short` description.