Generate shell completions for the Grok CLI
Generate shell completions for the Grok CLI
grok completions <shell> prints completion scripts for the Build CLI. Official: CLI Reference. Run grok completions --help (or grok --help) for the shell names your install accepts.
Generate a script
grok completions bash
grok completions zsh
grok completions fish
Redirect the output into the completion path your shell loads on startup. Examples (adjust paths for your OS and package manager):
# bash (user)
grok completions bash > ~/.local/share/bash-completion/completions/grok
# zsh (user fpath dir you already source)
grok completions zsh > ~/.zsh/completions/_grok
# fish
grok completions fish > ~/.config/fish/completions/grok.fish
Reload the shell (or source the completion file) so Tab completes grok subcommands and flags.
After an upgrade
Completions track the CLI you have installed. After grok update (see Update the Grok Build CLI), regenerate the script if new subcommands are missing from Tab.
Pitfalls
- The command prints the script. It does not install into
/etcfor you — write the file where your shell expects completions. - Completions are for the
grokbinary. They do not complete TUI slash commands inside a session (/model,/usage, …).