Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update shell_completions.md to have automatically rootcmd #1372

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions shell_completions.md
Expand Up @@ -28,17 +28,17 @@ and then modifying the generated `cmd/completion.go` file to look something like
var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate completion script",
Long: `To load completions:
Long: fmt.Sprintf(`To load completions:
Bash:
$ source <(yourprogram completion bash)
$ source <(%[1]s completion bash)
# To load completions for each session, execute once:
# Linux:
$ yourprogram completion bash > /etc/bash_completion.d/yourprogram
$ %[1]s completion bash > /etc/bash_completion.d/%[1]s
# macOS:
$ yourprogram completion bash > /usr/local/etc/bash_completion.d/yourprogram
$ %[1]s completion bash > /usr/local/etc/bash_completion.d/%[1]s
Zsh:
Expand All @@ -48,25 +48,25 @@ Zsh:
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
# To load completions for each session, execute once:
$ yourprogram completion zsh > "${fpath[1]}/_yourprogram"
$ %[1]s completion zsh > "${fpath[1]}/_%[1]s"
# You will need to start a new shell for this setup to take effect.
fish:
$ yourprogram completion fish | source
$ %[1]s completion fish | source
# To load completions for each session, execute once:
$ yourprogram completion fish > ~/.config/fish/completions/yourprogram.fish
$ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish
PowerShell:
PS> yourprogram completion powershell | Out-String | Invoke-Expression
PS> %[1]s completion powershell | Out-String | Invoke-Expression
# To load completions for every new session, run:
PS> yourprogram completion powershell > yourprogram.ps1
PS> %[1]s completion powershell > %[1]s.ps1
# and source this file from your PowerShell profile.
`,
`,cmd.Root().Name()),
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.ExactValidArgs(1),
Expand Down