Two builtin commands are available to manipulate the programmable completion facilities.
compgen
compgen [
option] [
word]
Generate possible completion matches for word according to
the options, which may be any option accepted by the
complete
builtin with the exception of -p and -r, and write
the matches to the standard output.
When using the -F or -C options, the various shell variables
set by the programmable completion facilities, while available, will not
have useful values.
The matches will be generated in the same way as if the programmable completion code had generated them directly from a completion specification with the same flags. If word is specified, only those completions matching word will be displayed.
The return value is true unless an invalid option is supplied, or no
matches were generated.
complete
complete [-abcdefgjksuv] [-o
comp-option] [-DE] [-A
action] [-G
globpat] [-W
wordlist] [-F
function] [-C
command] [-X
filterpat] [-P
prefix] [-S
suffix]
name[
name...]
complete -pr [-DE] [
name...]
Specify how arguments to each name should be completed. If the -p option is supplied, or if no options are supplied, existing completion specifications are printed in a way that allows them to be reused as input. The -r option removes a completion specification for each name, or, if no names are supplied, all completion specifications. The -D option indicates that the remaining options and actions should apply to the “default” command completion; that is, completion attempted on a command for which no completion has previously been defined. The -E option indicates that the remaining options and actions should apply to “empty” command completion; that is, completion attempted on a blank line.
The process of applying these completion specifications when word completion is attempted is described above (see Programmable Completion). The -D option takes precedence over -E.
Other options, if specified, have the following meanings.
The arguments to the -G, -W, and -X options
(and, if necessary, the -P and -S options)
should be quoted to protect them from expansion before the
complete
builtin is invoked.
-o
comp-optionbashdefault
default
dirnames
filenames
nospace
plusdirs
-A
actionalias
arrayvar
binding
builtin
command
directory
disabled
enabled
export
file
function
group
helptopic
help
builtin (see Bash Builtins).
hostname
job
keyword
running
service
setopt
set
builtin
(see The Set Builtin).
shopt
shopt
builtin
(see Bash Builtins).
signal
stopped
user
variable
-G
globpat-W
wordlist-C
command-F
function-X
filterpat-P
prefix-S
suffixThe return value is true unless an invalid option is supplied, an option
other than -p or -r is supplied without a name
argument, an attempt is made to remove a completion specification for
a name for which no specification exists, or
an error occurs adding a completion specification.
compopt
compopt
[-o option] [-DE] [+o option] [name]
Modify completion options for each name according to the
options, or for the currently-execution completion if no names
are supplied.
If no options are given, display the completion options for each
name or the current completion.
The possible values of option are those valid for the complete
builtin described above.
The -D option indicates that the remaining options should
apply to the “default” command completion; that is, completion attempted
on a command for which no completion has previously been defined.
The -E option indicates that the remaining options should
apply to “empty” command completion; that is, completion attempted on a
blank line.
The -D option takes precedence over -E.
The return value is true unless an invalid option is supplied, an attempt is made to modify the options for a name for which no completion specification exists, or an output error occurs.