Expand description
Implements programmable command completion support.
There are two ways in:
Shell::completecompletes a line at a cursor, as interactive completion does.Spec::generategenerates a spec’s candidates for a word on its own, as thecompgenbuiltin does.
Completing a line follows bash and readline:
- The word to complete (the text candidates replace, and a completion
function’s
$2) and the words ofCOMP_WORDSare found separately, and needn’t agree: after--opt=, the word to complete is empty, whileCOMP_WORDSends with=. - The spec to use is looked up:
complete -Eif there’s nothing before the cursor (and it isn’t at the start of a word),-Ifor the initial word, else the command’s, else-D. It’s looked up again each time a completion function asks for completion to restart, so specs it registered are used. - The spec generates candidates with a completion in progress on the shell,
so
compoptcan change its options. With no spec, basic completion completes variables, file names, and commands.
Structs§
- Complete
Action Iter - An iterator over the variants of CompleteAction
- Complete
Option Iter - An iterator over the variants of CompleteOption
- Completions
- Represents a set of generated command completions.
- Config
- Encapsulates the shell’s programmable command completion configuration.
- Fallback
Options - Options for fallback completions.
- Generation
Options - Options for generating completions: which
CompleteOptions are enabled. - Processing
Options - Options governing how command completion candidates are processed after being generated.
- Spec
- Encapsulates a command completion specification; provides policy for how to generate completions for a given input.
- Special
Spec Iter - An iterator over the variants of SpecialSpec
Enums§
- Complete
Action - Type of action to take to generate completion candidates. Each one’s name
(e.g.
arrayvar) is whatcomplete -Atakes. - Complete
Option - Options influencing how command completions are generated. Each one’s name
(e.g.
nospace) is whatcomplete -otakes; they’re declared in the order bash lists them. - Spec
Name - Names a completion spec in a
Config. - Special
Spec - A completion spec used in place of a command’s.