#compdef bst _bst_cmpl() { local idx completions name idx="${#words[@]}" # ZSH arrays start at 1 let idx=idx-1 completions=( $( env COMP_WORDS="$words" \ COMP_CWORD=$idx \ _BST_COMPLETION=complete bst ) ) for name in ${completions[@]}; do # For items that are an incomplete path, do not add trailing space if [[ $name = */ ]]; then compadd -S '' $name else A=($name) compadd -a A fi done return 0 } _bst_cmpl "$@"