The complete built-in generates completion candidates. This built-in can only be executed from completion functions during command line completion.


  • complete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] [-abcdfghjkuv] [[-O] [-D description] word…]


The built-in generates completion candidates according to the specified arguments. No matter how candidates are generated, only candidates that match the word being completed are generated.


-A pattern

Only accept candidates that match the pattern specified by this option. When more than one of this option is specified, only candidates that match all of the patterns are generated.

-D description

Give a description of the word candidates. The description is shown beside the candidates in the candidate list.


The candidates are treated as command line options. A hyphen is prepended to each candidate that is treated as an option.

-P prefix

Ignore prefix of the word being completed when generating candidates. The specified prefix must be initial part of the word.

If the word being completed is file:///home/user/docume for example, the command line complete -P file:// -f will generate pathname candidates that complete /home/user/docume.

-R pattern

Reject candidates that match the pattern specified by this option. When more than one of this option is specified, only candidates that match none of the patterns are generated.

-S suffix

Append suffix to each generated candidate.


Do not append a space after the word is completed. Without this option, a space is appended to the completed word so that you do not have to enter a space before the next word.

Options that select candidate types


Aliases. (same as --normal-alias --global-alias)




Line-editing commands the bindkey built-in accepts.


Built-in commands. (same as --special-builtin --mandatory-builtin --elective-builtin --extension-builtin --substitutive-builtin)


Commands. (same as --builtin-command --external-command --function)




Valid indices of the directory stack.


Elective built-in commands.


Executable regular files.


Extension built-in commands.


External commands.


Files (including directories).


Job IDs of finished jobs.




Global aliases.


User groups.


Host names.


Job IDs.




Mandatory built-in commands.


Normal aliases.


Obsolete synonym for --extension-builtin --substitutive-builtin.


Job IDs of jobs that are being executed.


Variables that are not arrays.


Obsolete synonym for --mandatory-builtin --elective-builtin.




Special built-in commands.


Job IDs of jobs that are suspended.


Substitutive built-in commands.


Users' log-in names.



If the -d (--directory) option is specified without the -f (--file) option, the -S / -T options are assumed.

Generated candidates for job IDs do not have leading percent signs (%). If the word being completed starts with a percent sign, the -P % option should be specified.


Operands are treated as completion candidates.

Exit status

The exit status of the built-in is zero if one or more candidates were generated, one if no candidates were generated, or larger than one if an error occurred.


The complete built-in is an elective built-in. It can be used in completion functions even in the POSIXly-correct mode because the mode is temporarily disabled during completion.