openclaw completion: Generate and Install Shell Completion Scripts
This page covers the openclaw completion command for generating and installing shell completion scripts for zsh, bash, powershell, or fish. It is intended for users who want to enable tab completion in their shell for the OpenClaw CLI.
Read this when
- You want shell completions for zsh/bash/fish/PowerShell
- You need to cache completion scripts under OpenClaw state
openclaw completion
Shell completion scripts can be generated, stored in OpenClaw's state directory, and optionally added to your shell profile.
Usage
openclaw completion # print zsh script to stdout
openclaw completion --shell fish # print fish script
openclaw completion --write-state # cache scripts for all shells
openclaw completion --write-state --install # cache, then install in one step
openclaw completion --shell bash --write-state
Options
-s, --shell <shell>: specifies the shell (zsh,bash,powershell, orfish; defaults tozsh)-i, --install: installs completions by inserting a source line into your shell profile that points to the cached script--write-state: writes the completion script(s) to$OPENCLAW_STATE_DIR/completions(default~/.openclaw/completions) instead of standard output; when--shellis used, only that shell's script is written, otherwise all four are created-y, --yes: bypasses confirmation prompts during installation (useful for non-interactive sessions)
Install flow
The --install flag links your shell profile to the cached script, so the cache must already exist. If it doesn't, the operation fails and prompts you to run openclaw completion --write-state. To handle both steps at once, use --write-state --install. When --shell is omitted, --install determines the shell from $SHELL (with zsh as the fallback).
Installation inserts a small # OpenClaw Completion block into your shell profile and replaces any older source <(openclaw completion ...) lines with the cached source directive:
| Shell | Profile |
|---|---|
| bash | ~/.bashrc (uses ~/.bash_profile as a fallback when ~/.bashrc is absent) |
| fish | ~/.config/fish/config.fish |
| powershell | ~/.config/powershell/Microsoft.PowerShell_profile.ps1 (on Windows: Documents/PowerShell/Microsoft.PowerShell_profile.ps1, or Documents/WindowsPowerShell/... for Windows PowerShell) |
| zsh | ~/.zshrc |
Notes
- When neither
--installnor--write-stateis provided, the script is printed to standard output. - Generating completions loads the entire command tree eagerly, including plugin CLI commands, so all nested subcommands appear in the output.
- After a successful update,
openclaw updateautomatically refreshes the completion cache;openclaw doctorcan fix missing or outdated completion configurations.