Skip to content

Commit

Permalink
Allow sourcing zsh completion script
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
marckhouzam committed Feb 26, 2023
1 parent 567ea8e commit b6b9abd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion completions.go
Expand Up @@ -734,7 +734,7 @@ to enable it. You can execute the following once:
To load completions in your current shell session:
source <(%[1]s completion zsh); compdef _%[1]s %[1]s
source <(%[1]s completion zsh)
To load completions for every new session, execute once:
Expand Down
1 change: 1 addition & 0 deletions zsh_completions.go
Expand Up @@ -90,6 +90,7 @@ func genZshComp(buf io.StringWriter, name string, includeDesc bool) {
compCmd = ShellCompNoDescRequestCmd
}
WriteStringAndCheck(buf, fmt.Sprintf(`#compdef %[1]s
compdef _%[1]s %[1]s
# zsh completion for %-36[1]s -*- shell-script -*-
Expand Down

0 comments on commit b6b9abd

Please sign in to comment.