Skip to main content

Module completion

Module completion 

Source
Expand description

Implements programmable command completion support.

There are two ways in:

  • Shell::complete completes a line at a cursor, as interactive completion does.
  • Spec::generate generates a spec’s candidates for a word on its own, as the compgen builtin does.

Completing a line follows bash and readline:

  1. The word to complete (the text candidates replace, and a completion function’s $2) and the words of COMP_WORDS are found separately, and needn’t agree: after --opt=, the word to complete is empty, while COMP_WORDS ends with =.
  2. The spec to use is looked up: complete -E if there’s nothing before the cursor (and it isn’t at the start of a word), -I for 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.
  3. The spec generates candidates with a completion in progress on the shell, so compopt can change its options. With no spec, basic completion completes variables, file names, and commands.

Structs§

CompleteActionIter
An iterator over the variants of CompleteAction
CompleteOptionIter
An iterator over the variants of CompleteOption
Completions
Represents a set of generated command completions.
Config
Encapsulates the shell’s programmable command completion configuration.
FallbackOptions
Options for fallback completions.
GenerationOptions
Options for generating completions: which CompleteOptions are enabled.
ProcessingOptions
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.
SpecialSpecIter
An iterator over the variants of SpecialSpec

Enums§

CompleteAction
Type of action to take to generate completion candidates. Each one’s name (e.g. arrayvar) is what complete -A takes.
CompleteOption
Options influencing how command completions are generated. Each one’s name (e.g. nospace) is what complete -o takes; they’re declared in the order bash lists them.
SpecName
Names a completion spec in a Config.
SpecialSpec
A completion spec used in place of a command’s.