From 37d481d4d40a07b1a8f2f6c345124540e870c85c Mon Sep 17 00:00:00 2001 From: Tom Payne <twpayne@gmail.com> Date: Sun, 5 Jun 2022 21:45:59 +0200 Subject: [PATCH] fix: Don't complete _command on zsh (#1690) Previously the generated zsh completion script started with the line #compdef _<command> <command> where <command> is the command that the zsh completion script is generated for. This enabled completions for both <command> and _<command>, but _<command> is the completion function itself and should not be completed. Furthermore, attempting to autocomplete _<command> (e.g. typing "_<command><Space><Tab>" in a zsh shell) causes zsh to hang. This commit fixes the #compdef line to only complete <command>, not _<command>. Co-authored-by: Arvid Norlander <VorpalBlade@users.noreply.github.com> --- zsh_completions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh_completions.go b/zsh_completions.go index c6048a9e..072921f9 100644 --- a/zsh_completions.go +++ b/zsh_completions.go @@ -75,7 +75,7 @@ func genZshComp(buf io.StringWriter, name string, includeDesc bool) { if !includeDesc { compCmd = ShellCompNoDescRequestCmd } - WriteStringAndCheck(buf, fmt.Sprintf(`#compdef _%[1]s %[1]s + WriteStringAndCheck(buf, fmt.Sprintf(`#compdef %[1]s # zsh completion for %-36[1]s -*- shell-script -*-