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 opts=('add delete export finger help list-keys recv-keys updatedb verify
35 version config edit-key gpgdir import import-trustdb init keyserver
36 list-sigs lsign-key populate refresh-keys'
37 'a d e f h l r u v V')
38 if [[ $prev = 'pacman-key' ]]; then
41 $prev != -@(a|-add|c|-config|g|-gpgdir|h|-help|import?(-trustdb)) ]]; then
50 _get_comp_words_by_ref cur prev
51 if [[ $cur = -* && ! $prev =~ ^-(-(config|help)$|\w*[Chp]) ]]; then
52 opts=('allsource asroot check clean config force geninteg help holdver ignorearch
53 install log nobuild nocheck nocolor noconfirm nodeps noextract noprogressbar
54 nosign pkg repackage rmdeps sign skipinteg source syncdeps'
55 'A L R S c d e f g h i m o p r s')
64 \pacman -$1 2>/dev/null | \cut -d' ' -f1 | \sort -u
66 \pacman -$1 2>/dev/null
72 local common core cur database prev query remove sync upgrade o
74 _get_comp_words_by_ref cur prev
75 database=('asdeps asexplicit')
76 query=('changelog check deps explicit file foreign groups info list owns
77 search unrequired upgrades' 'c e g i k l m o p s t u')
78 remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c n p s u')
79 sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore ignoregroup
80 info list needed nodeps print refresh recursive search sysupgrade'
82 upgrade=('asdeps asexplicit force needed nodeps print recursive' 'p')
83 common=('arch cachedir config dbpath debug help logfile noconfirm
84 noprogressbar noscriptlet quiet root verbose' 'b d h q r v')
85 core=('database help query remove sync upgrade version' 'D Q R S U V h')
87 for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade'; do
88 _arch_incomp "$o" && break
91 if [[ $? != 0 ]]; then
93 elif [[ ! $prev =~ ^-\w*[Vbhr] &&
94 ! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]]
96 [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common ||
101 { _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||
102 { _arch_incomp 'p file' && _pacman_file; } ||
103 _arch_incomp 'o owns' || _arch_incomp 'u upgrades' ||
106 { _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
107 { _arch_incomp 'l list' && _pacman_pkg Sl sort; } ||
117 compopt -o filenames; _filedir 'pkg.tar*'
120 complete -F _pacman -o default pacman
121 complete -F _makepkg -o default makepkg
122 complete -F _pacman_key -o default pacman-key
124 # ex:et ts=2 sw=2 ft=sh