The syntax of the form we'll discuss is essentially:
compctl [ -CDT ] options [command ...]
compctl
on the command line.
options specify all types of items you'd
like eligible for completion. (Variables, options, filenames, jobs, etc.)
You can see all current definitions in a short form by typing
compctl with no arguments.
comp_login_cmds:
> cat ./zsh/comp_login_cmds www.nebcorp.com www.acm.uiuc.edu schrof.net www.meat.net www.zsh.org >
Now for the command line. Let's throw in some cool tricks, too. We'll start with the full command line, and break it down:
compctl -k "( ` < ./zsh/comp_login_cmds `)" telnet rlogin rsh ssh
Now, we look at the command line above:
comptctl starts off the definition
telnet rsh rlogin ssh are the commands that this
completion will work for.
-k says that the items that will be used for
completion will come from an array. With -k, the array
following is either the name of an array, or an actual array
definition inside double-quotes.
` `) run a command in zsh, and replace
the command output on the command line.
cat on its arguments. Above, therefore, zsh runs the
command cat ./zsh/comp_login_cmds and the output gets placed
on the command line.
Assuming we have a list of hosts in comp_login_cmds, the command line now internally looks like:
compctl -k "( www.nebcorp.com www.acm.uiuc.edu schrof.net
www.meat.net www.zsh.org)" telnet rlogin rsh ssh
There you have it. Now, you can type:
> ssh www.< TAB >
and zsh will present you with all items that start with
www. If you had entered:
> ssh www.a< TAB >
zsh would know that there is only one item that starts with
www.a, and therefore replace it with
www.acm.uiuc.edu