zsh
is great but its completion system is very diverse. And the documentation lacks good examples. Is there a template for completing for a specific application. Th
Without changing anything further in .zshrc
(I already have autoload -Uz compinit
compinit
) I added the following as /usr/local/share/zsh/site-functions/_drush
#compdef drush
_arguments "1: :($(/usr/local/bin/aliases-drush.php))"
Where /usr/local/bin/aliases-drush.php
just prints a list of strings, each string being a potential first argument for the command drush. You could use ($(< filename))
to complete from filename
.
I based this on https://unix.stackexchange.com/a/458850/9452 -- it's surprising how simple this is at the end of the day.