zsh: Completion Widget Example

Previous: Completion Matching Control, Up: Completion Widgets [Contents][Index]

### 19.6 Completion Widget Example

The first step is to define the widget:

    zle -C complete complete-word complete-files

Then the widget can be bound to a key using the `bindkey` builtin command:

    bindkey '^X\t' complete

After that the shell function `complete-files` will be invoked after typing control-X and TAB. The function should then generate the matches, e.g.:

    complete-files () { compadd - * }

This function will complete files in the current directory matching the current word.