4 local cur prev longopts ng_set aurget_exec aurget
6 # save current nullglob setting and turn it on
7 ng_set
=$
(shopt -p nullglob
)
11 cur
=${COMP_WORDS[COMP_CWORD]}
12 prev
=${COMP_WORDS[COMP_CWORD-1]}
15 aurget_exec
=$
(type -P aurget
)
16 [[ -z "$aurget_exec" ]] && return 0
18 # get short executable too
19 aurget
=$
(basename "$aurget_exec")
23 longopts
='--devel --deps --nodeps --edit --noedit \
24 --discard --nodiscard --nocolor --noconfirm'
27 allopts
='-S -Sd -Sb -Sy -Su -Sdu -Sbu -Syu -Ss -Ssq -Sp -Si \
28 --devel --deps --nodeps --edit --noedit --discard \
29 --nodiscard --nocolor --noconfirm --ignore --mopt \
30 --popt --version --help'
32 if [[ $
(id
-u) -eq 0 ]]; then
33 aurget_exec
+=' --asroot'
38 # complete with all opts
39 *$aurget) COMPREPLY
=( $
(compgen
-W "$allopts" -- $cur) ) ;;
41 # don't complete boyond these
42 -h|
-v|
--@
(help|version|ignore|@
(m|p
)opt
)) return 0 ;;
44 # complete with long opts
45 -S*u
*|
--*) COMPREPLY
=( $
(compgen
-W "$longopts" -- $cur) ) ;;
47 # complete with package search
48 -S*) COMPREPLY
=( $
(compgen
-W "$($aurget_exec -Ssq $cur)" -- $cur ) ) ;;
51 # restore the previous nullglob setting
55 complete
-F _aurget aurget