Now that we've seen some examples, we're in a better position to consider the syntax of the complete command more systematically. complete has several elements because it needs several kinds of information:
command is the name of the command to be completed. The argument following it is the rule describing how to complete words for the command.
Completion rules consist of the following parts:
pattern describe how to choose words to be completed.
list specifies the word list from which to choose completions, e.g., names of files, users, groups, or variables. Alternatively, you can supply your own list of words or run a command to generate them.
suffix lets you specify a suffix other than space or slash to be added to a successful completion.
suffix is optional, but should be a single character if given. To specify explicitly that no suffix at all should be added, include another slash immediately following the one after
A completion rule should be quoted if it contains characters like
* that are special to the shell. I find it easiest simply to quote all my rules.
The parts of a completion rule are usually delimited with slashes, but you can use a different character, as shown below:
complete man 'p,*,c,' Comma delimiter complete cd 'p:1:d:' Colon delimiter
pattern values work together to determine which word or words the completion rule applies to. You can ...