#compdef compdef local expl func base=2 while [[ $words[base] = -* ]]; do case $words[base] in -d) delete=yes ;; -p) type=pattern ;; -k) type=key ;; esac (( base++ )) done if [ "$delete" ]; then _tags any:argument commands || return 1 _description expl 'completed command' compadd "$expl[@]" - ${(k)_comps} else if [[ CURRENT -eq base ]]; then _tags any:argument functions || return 1 _description expl 'completion function' compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t) else _command_names fi fi