1 # This file is in the public domain.
5 COMPREPLY=($(compgen -W '$*' -- "$cur"))
6 for ((i=1; i < ${#COMP_WORDS[@]}-1; i++)); do
7 for r in ${!COMPREPLY[@]}; do
8 if [[ ${COMP_WORDS[i]} = ${COMPREPLY[r]} ]]; then
9 unset 'COMPREPLY[r]'; break
18 for y in '0 --' '1 -'; do
19 eval 'set -- ${'$x'[${y% *}]}'
20 list+=\ ${@/#/${y#* }}
27 local r="\s-(-${1#* }\s|\w*${1% *})"; [[ $COMP_LINE =~ $r ]]
34 prev=${COMP_WORDS[COMP_CWORD-1]}
35 if [[ $cur = -* && ! $prev =~ ^-(-(cleancache|config|help)$|\w*[Chp]) ]]; then
36 opts=('allsource asroot clean cleancache config force geninteg help holdver
37 ignorearch install log nobuild nocolor noconfirm nodeps noextract
38 noprogressbar pkg repackage rmdeps skipinteg source syncdeps'
39 'A C L R c d e f g h i m o p r s')
48 \pacman -$1 | \cut -d' ' -f1 | \sort -u
56 local common core cur database prev query remove sync upgrade o
59 prev=${COMP_WORDS[COMP_CWORD-1]}
60 database=('asdeps asexplicit')
61 query=('changelog check deps explicit file foreign groups info list owns
62 search unrequired upgrades' 'c e g i k l m o p s t u')
63 remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c k n p s u')
64 sync=('asdeps asexplicit clean downloadonly force groups ignore ignoregroup
65 info list needed nodeps print refresh search sysupgrade'
66 'c f g i l p s u w y')
67 upgrade=('asdeps asexplicit force nodeps print' 'f p')
68 common=('arch cachedir config dbpath debug help logfile noconfirm
69 noprogressbar noscriptlet quiet root verbose' 'b d h q r v')
70 core=('database help query remove sync upgrade version' 'D Q R S U V h')
72 for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade'; do
73 _arch_incomp "$o" && break
76 if [[ $? != 0 ]]; then
78 elif [[ ! $prev =~ ^-\w*[Vbhr] &&
79 ! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]]
81 [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common ||
86 { _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||
87 { _arch_incomp 'p file' && _pacman_file; } ||
88 _arch_incomp 'o owns' || _arch_incomp 'u upgrades' ||
91 { _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
92 { _arch_incomp 'l list' && _pacman_pkg Sl sort; } ||
101 if [[ $(type -t compopt) = "builtin" ]]; then
103 compopt -o filenames; _filedir 'pkg.tar.*'
105 complete -F _pacman -o default pacman
110 complete -F _pacman -o filenames -o default pacman
113 complete -F _makepkg -o default makepkg
115 # ex:et ts=2 sw=2 ft=sh