6 local cur prev words cword
7 _get_comp_words_by_ref cur prev words cword
9 declare -A default_cmds
12 source .
/command_opts.sh
16 # complete subcommands
17 if [[ $cword -eq 1 ]]; then
18 COMPREPLY=( $(compgen -W "${!default_cmds[*]}" -- "$cur") )
22 # If there's an override for subcommand, use it
23 if declare -F "_aurutils_${words[1]/-/_/}" >/dev/null ; then
24 "_aurutils_${words[1]}"
28 # Complete with the generated opts stored above, unless the previous option
29 # is stored with an : suffix, because the option requires an argument.
30 # Fallback to default (files) completion in such cases.
35 _fallback_completion(){
36 opts=(${default_cmds[${words[1]}]})
37 if [[ ${opts[*]} != *$prev:* ]] || [[ $cword -eq 2 ]]; then
38 COMPREPLY=($(compgen -W "${opts[*]%:}" -- "$cur"));
42 _complete_with_repos() {
43 opts=($(aur repo --repo-list))
44 COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
50 _complete_with_repos ;;
51 *) _fallback_completion ;;
58 _complete_with_repos ;;
59 *) _fallback_completion ;;
63 _aurutils_repo_filter() {
66 _complete_with_repos ;;
67 *) _fallback_completion ;;
74 _complete_with_repos ;;
75 *) _fallback_completion ;;
79 complete -o bashdefault -o default -o nosort -F _aur_completion aur