Skip to content

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.

Terminal window
polytoken completions bash

Replace bash with zsh, fish, powershell, or elvish for the corresponding shell.

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.

Terminal window
polytoken completions bash > ~/.local/share/bash-completion/completions/polytoken

Restart 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:

Terminal window
fpath+=~/.zfunc

Then generate the completion:

Terminal window
polytoken completions zsh > ~/.zfunc/_polytoken

Restart your shell or run autoload -Uz compinit && compinit to activate completions.

Terminal window
polytoken completions fish > ~/.config/fish/completions/polytoken.fish

Fish loads completions automatically. Restart your shell to activate completions in the current session.

Append to your PowerShell profile rather than overwriting it:

Terminal window
polytoken completions powershell | Add-Content -Path $PROFILE

Reload the profile to activate completions:

Terminal window
. $PROFILE
Terminal window
polytoken completions elvish > ~/.config/elvish/lib/polytoken.elv

Restart your shell or run use polytoken to activate completions.

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.

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.