.. default-role:: code

:index:`complete` -- command completion
=======================================

Synopsis
--------
| complete [flags] [word...]

Description
-----------
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 to standard output in a way that allows them to
be reused as input.  The `-r` option removes a completion specification for
each *name*, or if no *name*\s are supplied, all completion specifications.

Flags
-----
:-A *action*: *action* may be one of the following list of completions:

   :alias: Equivalent to `-a`.
   :arrayvar: Array variable names.
   :binding: breadline` key binding names.
   :builtin: Equivalent to `-b`.
   :command: Equivalent to `-c`.
   :directory: Equivalent to `-d`.
   :disabled: Names of disabled shell builtins.
   :enabled: Names of enabled shell builtins.
   :export: Equivalent to `-e`.
   :file: Equivalent to `-f`.
   :function: Names of shell functions.
   :group: Equivalent to `-g`.
   :helptopic: Help topics as accepted by the `help` builtin.
   :hostname: Hostnames, as taken from the file specified by the `HOSTFILE` shell variable.
   :job: Equivalent to `-j`.
   :keyword: Equivalent to `-k`.
   :running: Names of running jobs if job control is active.
   :service: Equivalent to `-s`.
   :setopt: Valid option names as acceptered by the `shopt` builtin.
   :signal: Signal names.
   :stopped: Names of stopped jobs if job control is active.
   :user: Equivalent to `-u`.
   :variable: Equivalent to `-v`.

:-o *option*: *option* may be one of the following list of completions:

   :bashdefault: perform `bash` default completions if there are no matches
   :default: Use default filename completion of there are no matches.
   :dirnames: Perform directory name completion if there are no matches.
   :filenames: Match file names.
   :nospace: No space will be appended to words completed at the end of the line.

:-G *globpat*: The filename expansion pattern *globpat* is expanded to
   generate the possible completions.

:-W *wordlist*: The *wordlist* is split using the characters in
   `IFS` as delimiters, and the resultant word is expanded.  The possible
   completions are the members of the resultant list which match the word
   being completed.

:-C *command*: *command* is executed in a subshell environment, and
   its output is used as the possible completions.

:-D: Use this completion as a default for commands that don't have a
   completion specified.

:-E: Use this completion when for a blank line.

:-F *function*: The shell function *function* is executed in the
   current environment.  When it finishes the possible list of completions
   are retrieved from the indexed array variable `COMPREPLY`.

:-X *pattern*: *pattern* is used to filter filename expansions.  It is
   applied to the list of possible completions generated by the preceding
   options and arguments, and each completion matching *pattern* is removed
   from the list.  A leading `!` in *pattern* negates the pattern.

:-P *prefix*: *prefix* is prepended to each possible completion after
   all other options have been applied.

:-S *suffix*: *suffix* is appended to each possible completion after
   all other options have been applied.

:-a: Generate the list of alias names.

:-b: Generate the list of builtins.

:-c: Generate the list of command names.

:-d: Generate the list of directory names.

:-e: Generate the list of exported variable names.

:-f: Generate the list of file names.

:-g: Generate the list of group names.

:-j: Generate the list of job names if job control is active.

:-k: Generate the list of shell reserved words.

:-p: Existing options for *word* are written to standard output in a
   format "that can be used for reinput.

:-r: Removes the completion specification for each *word*.

:-s: Generate the list of service names.

:-u: Generate the list of user names.

:-v: Generate the list of variable names.

Exit Status
-----------
:0: No errors occurred.

:>0: An error occurred.

See Also
--------
`compgen`\(1), `readonly`\(1), `export`\(1)
