unstable-dynamic only.Expand description
COMPLETE=$SHELL <bin> completion integration
See CompleteEnv:
fn cli() -> clap::Command {
// ...
}
fn main() {
CompleteEnv::with_factory(cli)
.complete();
// ... rest of application logic
}To customize completions, see
To source your completions:
WARNING: We recommend re-sourcing your completions on upgrade.
These completions work by generating shell code that calls into your_program while completing.
That interface is unstable and a mismatch between the shell code and your_program may result
in either invalid completions or no completions being generated.
For this reason, we recommend generating the shell code anew on shell startup so that it is
“self-correcting” on shell launch, rather than writing the generated completions to a file.
Bash
echo "source <(COMPLETE=bash your_program)" >> ~/.bashrcElvish
echo "eval (E:COMPLETE=elvish your_program | slurp)" >> ~/.elvish/rc.elvFish
echo "COMPLETE=fish your_program | source" >> ~/.config/fish/config.fishPowershell
echo '$env:COMPLETE = "powershell"; your_program | Out-String | Invoke-Expression; Remove-Item Env:\COMPLETE' >> $PROFILENote that to execute scripts in PowerShell on Windows, including $PROFILE,
the execution policy needs to be set to RemoteSigned at minimum.
Zsh
echo "source <(COMPLETE=zsh your_program)" >> ~/.zshrcTo disable completions, you can set COMPLETE= or COMPLETE=0
Structs§
- Bash
- Bash completion adapter
- Complete
Env - Environment-activated completions for your CLI
- Elvish
- Elvish completion adapter
- Fish
- Fish completion adapter
- Powershell
- Powershell completion adapter
- Shells
- Collection of shell-specific completers
- Zsh
- Zsh completion adapter
Traits§
- EnvCompleter
- Shell-integration for completions