Shell Completions
Polytoken generates completion scripts for bash, zsh, fish, PowerShell, and Elvish. The completions command writes the script to stdout. Redirect the output to the location your shell expects.
Generate completions
Section titled “Generate completions”polytoken completions bashReplace bash with zsh, fish, powershell, or elvish for the corresponding shell.
Install completions
Section titled “Install completions”The commands below write the completion script to the default location for each shell. Paths use the default $XDG_* directory; substitute if you have set the corresponding variable.
The bash-completion package must be installed on your system.
polytoken completions bash > ~/.local/share/bash-completion/completions/polytokenRestart your shell or run source ~/.local/share/bash-completion/completions/polytoken to activate completions in the current session.
The directory containing the completion file must be on your fpath before compinit runs. Add this to your ~/.zshrc if it is not already present:
fpath+=~/.zfuncThen generate the completion:
polytoken completions zsh > ~/.zfunc/_polytokenRestart your shell or run autoload -Uz compinit && compinit to activate completions.
polytoken completions fish > ~/.config/fish/completions/polytoken.fishFish loads completions automatically. Restart your shell to activate completions in the current session.
PowerShell
Section titled “PowerShell”Append to your PowerShell profile rather than overwriting it:
polytoken completions powershell | Add-Content -Path $PROFILEReload the profile to activate completions:
. $PROFILEElvish
Section titled “Elvish”polytoken completions elvish > ~/.config/elvish/lib/polytoken.elvRestart your shell or run use polytoken to activate completions.
--model completion
Section titled “--model completion”For polytoken new --model <TAB>, polytoken new --model=<TAB>, and the same
positions on polytoken exec, completions come from the effective runtime
model catalog — every configured model plus its reasoning effort-suffix
references like model(high) or model(none) — never from files in your
working directory. The lookup runs polytoken print models at TAB time
against the readable config, so dynamic provider catalogs are included.
Behavior is uniform across all five shells, though the mechanism differs per
shell: bash and zsh wrap the generated completer function and re-register the
wrapper; fish rewrites the generated --model rule to source model
candidates with no file fallback; PowerShell re-registers a dispatcher
around the generated scriptblock; Elvish extends the generated
arg-completer. Every hook suppresses the lookup’s stderr and returns zero
candidates on an unconfigured setup or lookup failure — you get an empty
model list, never files.
If your invocation carries a root --config-dir <dir> (or --config-dir=<dir>)
before the subcommand, every shell forwards it to the lookup, so the offered
models match the config your command will actually use.
Requirements
Section titled “Requirements”The completions command requires no configuration. It works immediately after installation, before any provider or config setup. The command bypasses the first-run configurator and tracing, so stdout contains only the completion script. The --model value lookup is likewise first-run-exempt and tracing-free; with no config in place it simply offers zero candidates.