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 ]]
31 \pacman-key --list-keys 2>/dev/null | awk '
34 split($2, a, "/"); print a[2]
38 if (match($NF, /<[^>]+>/))
39 print substr($NF, RSTART + 1, RLENGTH - 2)
44 local o cur opts prev wantfiles
46 _get_comp_words_by_ref cur prev
47 opts=('add delete export finger help list-keys recv-keys updatedb verify
48 version config edit-key gpgdir import import-trustdb init keyserver
49 list-sigs lsign-key populate refresh-keys'
50 'a d e f h l r u v V')
52 # operations for which we want to complete keyids
53 for o in 'd delete' 'e export' 'f finger' 'l list-keys' 'r recv-keys' \
54 'edit-key' 'list-sigs' 'refresh-keys'; do
55 _arch_incomp "$o" && break
59 # options for which we want file completion
60 wantfiles='-@(c|-config|g|-gpgdir)'
62 if [[ $prev = 'pacman-key' || ( $cur = -* && $prev != $wantfiles ) ]]; then
64 elif [[ $prev = @(-k|--keyserver) ]]; then
66 elif [[ $prev != $wantfiles && $o ]]; then
67 COMPREPLY=($(compgen -W '$(_pacman_keyids)' -- "$cur"))
75 _get_comp_words_by_ref cur prev
76 if [[ $cur = -* && ! $prev =~ ^-(-(config|help)$|\w*[Chp]) ]]; then
77 opts=('allsource asdeps asroot check clean config force geninteg help holdver ignorearch
78 install log nobuild nocheck nocolor noconfirm nodeps noextract
79 noprogressbar nosign pkg repackage rmdeps sign skipinteg source syncdeps'
80 'A L R S c d e f g h i m o p r s')
89 \pacman -$1 2>/dev/null | \cut -d' ' -f1 | \sort -u
91 \pacman -$1 2>/dev/null
97 local common core cur database prev query remove sync upgrade o
99 _get_comp_words_by_ref cur prev
100 database=('asdeps asexplicit')
101 query=('changelog check deps explicit file foreign groups info list owns
102 search unrequired upgrades' 'c e g i k l m o p s t u')
103 remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c n p s u')
104 sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore ignoregroup
105 info list needed nodeps print refresh recursive search sysupgrade'
107 upgrade=('asdeps asexplicit force needed nodeps print recursive' 'p')
108 common=('arch cachedir config dbpath debug help logfile noconfirm
109 noprogressbar noscriptlet quiet root verbose' 'b d h q r v')
110 core=('database help query remove sync upgrade version' 'D Q R S U V h')
112 for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade'; do
113 _arch_incomp "$o" && break
116 if [[ $? != 0 ]]; then
118 elif [[ ! $prev =~ ^-\w*[Vbhr] &&
119 ! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]]
121 [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common ||
126 { _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||
127 { _arch_incomp 'p file' && _pacman_file; } ||
128 _arch_incomp 'o owns' || _arch_incomp 'u upgrades' ||
131 { _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
132 { _arch_incomp 'l list' && _pacman_pkg Sl sort; } ||
142 compopt -o filenames; _filedir 'pkg.tar*'
145 complete -F _pacman -o default pacman
146 complete -F _makepkg -o default makepkg
147 complete -F _pacman_key -o default pacman-key
149 # ex:et ts=2 sw=2 ft=sh