Skip to content

Commit

Permalink
fix: repair zsh completion
Browse files Browse the repository at this point in the history
Cobra does not hook the ZSH completion rules, as it appears. Tools with
working ZSH cobra completion (helm, kubectl) do so by printing the hook
(`compdef _<completion> <tool>`) themselves.

Fixes #3318

Signed-off-by: Jorik Jonker <jorik@kippendief.biz>
  • Loading branch information
jonkerj authored and talos-bot committed Mar 21, 2021
1 parent fc9c416 commit aab49a1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/talosctl/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ talosctl completion zsh > "${fpath[1]}/_talosctl"`,
case "bash":
return rootCmd.GenBashCompletion(os.Stdout)
case "zsh":
return rootCmd.GenZshCompletion(os.Stdout)
err := rootCmd.GenZshCompletion(os.Stdout)
// cobra does not hook the completion, so let's do it manually
fmt.Printf("compdef _talosctl talosctl")

return err
default:
return fmt.Errorf("unsupported shell %q", args[0])
}
Expand Down

0 comments on commit aab49a1

Please sign in to comment.