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. For bash, fish, and Elvish, the install location sits under an $XDG_* directory: bash under $XDG_DATA_HOME (default: ~/.local/share), fish and Elvish under $XDG_CONFIG_HOME (default: ~/.config). Substitute your configured directory in those commands if you have set either variable. The zsh and PowerShell locations follow shell conventions rather than $XDG_*.
Polytoken’s bash script needs nothing besides Bash itself and the polytoken binary, so it runs without the bash-completion package. With bash-completion installed, Bash loads the completion file on demand the first time you complete a polytoken command, which is why the install command below writes to that directory. Without bash-completion, source the file from your Bash startup files instead.
mkdir -p ~/.local/share/bash-completion/completionspolytoken completions bash > ~/.local/share/bash-completion/completions/polytokenRestart your shell to activate completions, or run source ~/.local/share/bash-completion/completions/polytoken to activate them 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:
mkdir -p ~/.zfuncpolytoken completions zsh > ~/.zfunc/_polytokenRestart your shell or run autoload -Uz compinit && compinit to activate completions.
mkdir -p ~/.config/fish/completionspolytoken completions fish > ~/.config/fish/completions/polytoken.fishFish loads completions automatically. Restart your shell to activate completions.
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”mkdir -p ~/.config/elvish/libpolytoken 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, never from files in your working directory. The candidate list
covers every configured model plus its selectable references: reasoning
effort suffixes like model(high), the reasoning-off form model(none) where
the model allows disabling reasoning, and the thinking form model(t) for
models that support thinking. The lookup runs polytoken print models at TAB
time, so the candidate list includes dynamic provider catalogs. When the
lookup cannot resolve a dynamic catalog, it skips that catalog and offers the
models written in your config files.
Model completion behaves the same in all five shells. Each shell’s completion script suppresses lookup errors and returns zero candidates when no configuration exists or configuration loading fails, so 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 completion
scripts do not forward a root --working-dir. Without an explicit
--config-dir, the lookup reads project config from the directory your shell
is in, which can differ from the directory the command will run in.
Requirements
Section titled “Requirements”The completions command requires no configuration and works immediately after installation, before any provider or config setup. It never opens the first-run configurator, and stdout carries only the completion script. The --model value lookup skips the configurator too; with no config in place it offers zero candidates.