Programmable Completion


Before proceeding, keep the zshcompctl man page in mind. The syntax for completion can occasionally get a bit tricky.

Completion refers to zsh's ability to finish your command lines for you. It comes in many forms. By default, the < TAB > key is bound to a completion command in zsh.

A quick example:

  > ls
  array.NOTES  array.c      array.h      launch.c
  > wc -l arr< TAB >

Upon hitting the < TAB > key, zsh will take the string arr, and resolve it to a filename that starts with arr.

Since there is more than one file that mathes, you can make zsh present a menu of choices, or you can make zsh cycle through each option by hitting the < TAB > key repeatedly.

And this is just the beginning. Filenames are the default item to complete on. In zsh, ANYTHING can be completed, including: