#compdef shaft _shaft() { local curcontext="$curcontext" state line typeset -A opt_args _arguments \ '1: :->command'\ '*: :->tunnel' case $state in command) _arguments "1:Commands:(active start stop restart help all completions)" ;; *) case $words[2] in start) compadd "$@" `shaft all --short` ;; stop|restart) compadd "$@" `shaft active --short` ;; esac ;; esac } _shaft "$@"