Module bpaf::_documentation::_2_howto::_1_completion
source · extradocs
only.Expand description
§Dynamic shell completion
bpaf
implements shell completion to allow to automatically fill in not only flag and command
names, but also argument and positional item values.
-
Enable
autocomplete
feature:bpaf = { version = "0.9", features = ["autocomplete"] }
-
Decorate
argument
andpositional
parsers withParser::complete
to provide completion functions for arguments -
Depending on your shell generate appropriate completion file and place it to whereever your shell is going to look for it, name of the file should correspond in some way to name of your program. Consult manual for your shell for the location and named conventions:
-
bash
$ your_program --bpaf-complete-style-bash >> ~/.bash_completion
-
zsh: note
_
at the beginning of the filename$ your_program --bpaf-complete-style-zsh > ~/.zsh/_your_program
-
fish
$ your_program --bpaf-complete-style-fish > ~/.config/fish/completions/your_program.fish
-
elvish
$ your_program --bpaf-complete-style-elvish >> ~/.config/elvish/rc.elv
-
-
Restart your shell - you need to done it only once or optionally after bpaf major version upgrade: generated completion files contain only instructions how to ask your program for possible completions and don’t change even if options are different.
-
Generated scripts rely on your program being accessible in $PATH