_ant_does_target_list_need_generating () { local build_file=$1 [ ! -f .ant_targets ] && return 0; [ $build_file -nt .ant_targets ] && return 0; return 1; } _ant () { _arguments ':target:->target' '-f[build-file]:filename:->files' case "$state" in files) compadd -- $(grep -l --color=never " 5 { print lastTarget }{lastTarget = $1}' > .ant_targets fi compadd -- $(cat .ant_targets) fi ;; esac } compdef _ant ant