O'Reilly logo

Using csh & tcsh by Paul DuBois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Syntax of the complete Command

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:

complete command word/pattern/list/suffix

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:

  • word and 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 list.

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

Selecting the Word To Be Completed

The word and pattern values work together to determine which word or words the completion rule applies to. You can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required