Programmed Completions
tcsh has programmed completions, a facility that allows you to associate specific types of completion with individual commands. This feature is useful when the built-in completion behavior, described in the preceding sections, doesn't complete words the way you want. For example, you might want to complete an argument as a username, or complete some arguments differently than others, or determine how to complete a word based on what the preceding word looks like.
Programmed completions are triggered the same way as regular completions (TAB
completes a word and CTRL-D
displays possible matches), but you specify their behavior using the complete command. The syntax of complete is rather cumbersome, so we'll wait until later in the chapter to examine it more closely. First, we'll look at some examples of complete to get a general idea of how it works. (You can find many more programmed completion examples in the file complete.tcsh included with the tcsh source distribution. It provides ready-made completions that you can borrow, and it will give you ideas for creating your own. If you don't have that distribution, Appendix C, Other Sources of Information, indicates how to obtain complete.tcsh separately.)
Programmed completions are best placed in your ˜/.cshrc file so they're available to your login shell as well as any subshells.[18] Don't put a complete command in ˜/.cshrc until you've verified that it works correctly. Define the completion at the command line ...
Get Using csh & tcsh now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.