#compdef -command- local nm=$compstate[nmatches] ret=1 expl # Complete jobs in implicit fg and bg if [[ "$PREFIX[1]" = "%" ]]; then _description expl job compgen "$expl[@]" -j -P '%' [[ nm -ne compstate[nmatches] ]] && return fi _description expl command compgen "$expl[@]" -c && ret=0 if [[ nm -eq compstate[nmatches] ]]; then _description expl 'executable file or directory' _path_files "$expl[@]" -/g "*(*)" else return ret fi