Codex shell completions make the terminal suggest CLI subcommands, options, and shell-specific arguments while entering codex commands. Generating the script from the installed CLI keeps those suggestions aligned with the commands and flags available on that machine.
Completion scripts use the syntax and conventions of the destination shell. The Codex CLI must already be installed, but generating a script requires no sign-in or active agent session.
A generated script reflects the Codex release that produced it, so a CLI upgrade can leave an older script missing new commands or flags. Generation writes script text without enabling completion in the shell.
Steps to generate shell completions for Codex:
- Generate the zsh completion script as _codex in the current directory.
For zsh, _codex is the conventional completion-function filename. The output path is ./_codex; redirection replaces any existing file there.
$ codex completion zsh \ > _codex
- Inspect the first line of the saved completion file.
$ head -n 1 _codex #compdef codex
The #compdef codex header identifies a zsh completion script for Codex. An empty result or a file-not-found error means the script was not saved as expected. The file remains in the current directory; generating it does not enable completion in the shell.