Skip to content
Myr

Update shell_completions.md to have automatically rootcmd (#1372)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Update shell_completions.md

authored by Ron Green · committed by GitHub · parent 6f19fa9 · Browse files · 1 file+10 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−10 removed

  • other:+10 added−10 removed

1 file+10 added−10 removed

modified:shell_completions.md+10 added-10 removed
26 unmodified lines
27```go28var completionCmd = &cobra.Command{29 Use: "completion [bash|zsh|fish|powershell]",30 Short: "Generate completion script",31 Long: `To load completions:31 Long: fmt.Sprintf(`To load completions:3233Bash:3435 $ source <(yourprogram completion bash)35 $ source <(%[1]s completion bash)3637 # To load completions for each session, execute once:38 # Linux:39 $ yourprogram completion bash > /etc/bash_completion.d/yourprogram39 $ %[1]s completion bash > /etc/bash_completion.d/%[1]s40 # macOS:41 $ yourprogram completion bash > /usr/local/etc/bash_completion.d/yourprogram41 $ %[1]s completion bash > /usr/local/etc/bash_completion.d/%[1]s4243Zsh:4445 # If shell completion is not already enabled in your environment,
1 unmodified line
4748 $ echo "autoload -U compinit; compinit" >> ~/.zshrc4950 # To load completions for each session, execute once:51 $ yourprogram completion zsh > "${fpath[1]}/_yourprogram"51 $ %[1]s completion zsh > "${fpath[1]}/_%[1]s"5253 # You will need to start a new shell for this setup to take effect.5455fish:5657 $ yourprogram completion fish | source57 $ %[1]s completion fish | source5859 # To load completions for each session, execute once:60 $ yourprogram completion fish > ~/.config/fish/completions/yourprogram.fish60 $ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish6162PowerShell:6364 PS> yourprogram completion powershell | Out-String | Invoke-Expression64 PS> %[1]s completion powershell | Out-String | Invoke-Expression6566 # To load completions for every new session, run:67 PS> yourprogram completion powershell > yourprogram.ps167 PS> %[1]s completion powershell > %[1]s.ps168 # and source this file from your PowerShell profile.69`,69`,cmd.Root().Name()),70 DisableFlagsInUseLine: true,71 ValidArgs: []string{"bash", "zsh", "fish", "powershell"},72 Args: cobra.ExactValidArgs(1),73 Run: func(cmd *cobra.Command, args []string) {
473 unmodified lines