Skip to content

Commit 45360a5

Browse files
authored
Allow sourcing zsh completion script (#1917)
Although it is not the recommended approach, sourcing a completion script is the simplest way to get people to try using shell completion. Not allowing it for zsh has turned out to complicate shell completion adoption. Further, many tools modify the zsh script to allow sourcing. This commit allows sourcing of the zsh completion script. Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
1 parent c8a20a1 commit 45360a5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

completions.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ to enable it. You can execute the following once:
734734
735735
To load completions in your current shell session:
736736
737-
source <(%[1]s completion zsh); compdef _%[1]s %[1]s
737+
source <(%[1]s completion zsh)
738738
739739
To load completions for every new session, execute once:
740740

zsh_completions.go

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func genZshComp(buf io.StringWriter, name string, includeDesc bool) {
9090
compCmd = ShellCompNoDescRequestCmd
9191
}
9292
WriteStringAndCheck(buf, fmt.Sprintf(`#compdef %[1]s
93+
compdef _%[1]s %[1]s
9394
9495
# zsh completion for %-36[1]s -*- shell-script -*-
9596

0 commit comments

Comments
 (0)