# bash completion for antifind: antifind --completions bash > /etc/bash_completion.d/antifind
_antifind() {
  local cur prev
  cur="${COMP_WORDS[COMP_CWORD]}"; prev="${COMP_WORDS[COMP_CWORD-1]}"
  case "$prev" in
    --sort) COMPREPLY=( $(compgen -W "name path size date ext none" -- "$cur") ); return ;;
    -t|--type) COMPREPLY=( $(compgen -W "f d l" -- "$cur") ); return ;;
    -e|--ext|-S|--size|--changed|--changed-before|-d|--max-depth|-n|--max|--limit|--since|--format) return ;;
    --color) COMPREPLY=( $(compgen -W "auto always never" -- "$cur") ); return ;;
    --completions|--shell-setup) COMPREPLY=( $(compgen -W "bash zsh fish powershell --remove" -- "$cur") ); return ;;
  esac
  case "$cur" in
    @*) COMPREPLY=( $(compgen -W "$(command antifind --saved-names 2>/dev/null)" -- "$cur") ) ;;
    saved:*) COMPREPLY=( $(compgen -P "saved:" -W "$(command antifind --saved-names 2>/dev/null | sed s/^@//)" -- "${cur#saved:}") ) ;;
    -*) COMPREPLY=( $(compgen -W "-e --ext -t --type -S --size --changed --changed-before -d --max-depth -i --ignore-case --case-sensitive --accents --no-accents -x --skipmount -a --all -n --max --limit --sort -r --reverse -l --long -c --count --format --json --jsonl -0 --null --raw --color -w --watch --since --print-query --alias --aliases --saved --save --forget --copy --param --describe --live --mark --marks --since-mark rules --on --min-size --quiet --rate --yes --allow-internet --allow-executables --notify --run --arg --copy-to --move-to --open --app --url --antipdf --antimail --created --modified --renamed --deleted --moved --attrs --grew --flat --by-folder --completions --shell-setup --remove --saved-names --status --reindex --linux-snapshots --remember --refresh-slow --socket --gui -h --help --version" -- "$cur") ) ;;
    type:*) COMPREPLY=( $(compgen -P "type:" -W "file folder link device other" -- "${cur#type:}") ) ;;
    scope:*) COMPREPLY=( $(compgen -P "scope:" -W "system all" -- "${cur#scope:}") ) ;;
    ext:*|size:*|dm:*|path:*|under:*) ;;
    *:*) ;;
    *) COMPREPLY=( $(compgen -d -- "$cur") $(compgen -W "ext: size: dm: changed: modified: created: accessed: ctime: type: path: name: glob: regex: owner: group: perm: depth: empty: mount: fs: under: skipmount: scope: case: nocase: accents: noaccents: wholeword: alias: saved: du changes rules" -- "$cur") ) ;;
  esac
}
complete -o nospace -F _antifind antifind
complete -o nospace -F _antifind af
