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 ]]
33 _get_comp_words_by_ref cur prev
34 if [[ $cur = -* && ! $prev =~ ^-(-(config|help)$|\w*[Chp]) ]]; then
35 opts=('allsource asroot check clean config force geninteg help holdver ignorearch
36 install log nobuild nocheck nocolor noconfirm nodeps noextract noprogressbar
37 nosign pkg repackage rmdeps sign skipinteg source syncdeps'
38 'A L R S c d e f g h i m o p r s')
47 \pacman -$1 | \cut -d' ' -f1 | \sort -u
55 local common core cur database prev query remove sync upgrade o
57 _get_comp_words_by_ref cur prev
58 database=('asdeps asexplicit')
59 query=('changelog check deps explicit file foreign groups info list owns
60 search unrequired upgrades' 'c e g i k l m o p s t u')
61 remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c n p s u')
62 sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore ignoregroup
63 info list needed nodeps print refresh recursive search sysupgrade'
64 'c f g i l p s u w y')
65 upgrade=('asdeps asexplicit force needed nodeps print recursive' 'f p')
66 common=('arch cachedir config dbpath debug help logfile noconfirm
67 noprogressbar noscriptlet quiet root verbose' 'b d h q r v')
68 core=('database help query remove sync upgrade version' 'D Q R S U V h')
70 for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade'; do
71 _arch_incomp "$o" && break
74 if [[ $? != 0 ]]; then
76 elif [[ ! $prev =~ ^-\w*[Vbhr] &&
77 ! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]]
79 [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common ||
84 { _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||
85 { _arch_incomp 'p file' && _pacman_file; } ||
86 _arch_incomp 'o owns' || _arch_incomp 'u upgrades' ||
89 { _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
90 { _arch_incomp 'l list' && _pacman_pkg Sl sort; } ||
99 if [[ $(type -t compopt) = "builtin" ]]; then
101 compopt -o filenames; _filedir 'pkg.tar.*'
103 complete -F _pacman -o default pacman
108 complete -F _pacman -o filenames -o default pacman
111 complete -F _makepkg -o default makepkg
113 # ex:et ts=2 sw=2 ft=sh