2010-05-18 18:26:47 -04:00
|
|
|
# This file is in the public domain.
|
|
|
|
|
|
|
|
_arch_compgen() {
|
|
|
|
local i r
|
|
|
|
COMPREPLY=($(compgen -W '$*' -- "$cur"))
|
|
|
|
for ((i=1; i < ${#COMP_WORDS[@]}-1; i++)); do
|
|
|
|
for r in ${!COMPREPLY[@]}; do
|
|
|
|
if [[ ${COMP_WORDS[i]} = ${COMPREPLY[r]} ]]; then
|
|
|
|
unset 'COMPREPLY[r]'; break
|
|
|
|
fi
|
2007-02-16 14:37:00 -05:00
|
|
|
done
|
2010-05-18 18:26:47 -04:00
|
|
|
done
|
2007-02-16 14:37:00 -05:00
|
|
|
}
|
|
|
|
|
2010-05-18 18:26:47 -04:00
|
|
|
_arch_ptr2comp() {
|
|
|
|
local list= x y
|
|
|
|
for x; do
|
|
|
|
for y in '0 --' '1 -'; do
|
|
|
|
eval 'set -- ${'$x'[${y% *}]}'
|
|
|
|
list+=\ ${@/#/${y#* }}
|
|
|
|
done
|
|
|
|
done
|
|
|
|
_arch_compgen $list
|
2007-02-16 14:37:00 -05:00
|
|
|
}
|
|
|
|
|
2010-05-18 18:26:47 -04:00
|
|
|
_arch_incomp() {
|
|
|
|
local r="\s-(-${1#* }\s|\w*${1% *})"; [[ $COMP_LINE =~ $r ]]
|
2007-02-16 14:37:00 -05:00
|
|
|
}
|
|
|
|
|
2011-09-25 14:32:15 -04:00
|
|
|
_pacman_key() {
|
|
|
|
local cur opts prev
|
|
|
|
COMPREPLY=()
|
|
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
if [[ $cur = -* &&
|
|
|
|
$prev != -@(a|-add|c|-config|g|-gpgdir|h|-help|import?(-trustdb)) ]]; then
|
|
|
|
opts=('add delete export finger help list-keys recv-keys updatedb verify version
|
|
|
|
config edit-key gpgdir import import-trustdb init keyserver list-sigs
|
|
|
|
lsign-key populate refresh-keys'
|
|
|
|
'a d e f h l r u v V')
|
|
|
|
_arch_ptr2comp opts
|
|
|
|
fi
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2010-05-18 18:26:47 -04:00
|
|
|
_makepkg() {
|
|
|
|
local cur opts prev
|
2007-02-16 14:37:00 -05:00
|
|
|
COMPREPLY=()
|
2010-10-13 00:46:35 -04:00
|
|
|
_get_comp_words_by_ref cur prev
|
2011-07-08 09:01:37 -04:00
|
|
|
if [[ $cur = -* && ! $prev =~ ^-(-(config|help)$|\w*[Chp]) ]]; then
|
2011-07-06 22:19:58 -04:00
|
|
|
opts=('allsource asroot check clean config force geninteg help holdver ignorearch
|
|
|
|
install log nobuild nocheck nocolor noconfirm nodeps noextract noprogressbar
|
|
|
|
nosign pkg repackage rmdeps sign skipinteg source syncdeps'
|
2011-08-18 06:46:19 -04:00
|
|
|
'A L R S c d e f g h i m o p r s')
|
2010-05-18 18:26:47 -04:00
|
|
|
_arch_ptr2comp opts
|
2007-02-16 14:37:00 -05:00
|
|
|
fi
|
2010-05-18 18:26:47 -04:00
|
|
|
true
|
2007-02-16 14:37:00 -05:00
|
|
|
}
|
|
|
|
|
2010-05-18 18:26:47 -04:00
|
|
|
_pacman_pkg() {
|
|
|
|
_arch_compgen "$(
|
|
|
|
if [[ $2 ]]; then
|
|
|
|
\pacman -$1 | \cut -d' ' -f1 | \sort -u
|
|
|
|
else
|
|
|
|
\pacman -$1
|
2007-02-18 23:13:13 -05:00
|
|
|
fi
|
2010-05-18 18:26:47 -04:00
|
|
|
)"
|
2007-02-16 14:37:00 -05:00
|
|
|
}
|
|
|
|
|
2010-05-18 18:26:47 -04:00
|
|
|
_pacman() {
|
|
|
|
local common core cur database prev query remove sync upgrade o
|
|
|
|
COMPREPLY=()
|
2010-10-13 00:46:35 -04:00
|
|
|
_get_comp_words_by_ref cur prev
|
2010-05-18 18:26:47 -04:00
|
|
|
database=('asdeps asexplicit')
|
|
|
|
query=('changelog check deps explicit file foreign groups info list owns
|
|
|
|
search unrequired upgrades' 'c e g i k l m o p s t u')
|
2011-08-11 09:37:04 -04:00
|
|
|
remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c n p s u')
|
2011-08-19 16:48:09 -04:00
|
|
|
sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore ignoregroup
|
2011-08-11 09:37:04 -04:00
|
|
|
info list needed nodeps print refresh recursive search sysupgrade'
|
2011-10-11 13:35:33 -04:00
|
|
|
'c g i l p s u w y')
|
|
|
|
upgrade=('asdeps asexplicit force needed nodeps print recursive' 'p')
|
2010-05-18 18:26:47 -04:00
|
|
|
common=('arch cachedir config dbpath debug help logfile noconfirm
|
|
|
|
noprogressbar noscriptlet quiet root verbose' 'b d h q r v')
|
|
|
|
core=('database help query remove sync upgrade version' 'D Q R S U V h')
|
|
|
|
|
|
|
|
for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade'; do
|
|
|
|
_arch_incomp "$o" && break
|
2007-02-16 14:37:00 -05:00
|
|
|
done
|
|
|
|
|
2010-05-18 18:26:47 -04:00
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
_arch_ptr2comp core
|
2010-07-26 10:49:43 -04:00
|
|
|
elif [[ ! $prev =~ ^-\w*[Vbhr] &&
|
|
|
|
! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]]
|
2010-05-18 18:26:47 -04:00
|
|
|
then
|
|
|
|
[[ $cur = -* ]] && _arch_ptr2comp ${o#* } common ||
|
|
|
|
case ${o% *} in
|
|
|
|
D|R)
|
|
|
|
_pacman_pkg Qq;;
|
2007-02-16 14:37:00 -05:00
|
|
|
Q)
|
2010-05-18 18:26:47 -04:00
|
|
|
{ _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||
|
|
|
|
{ _arch_incomp 'p file' && _pacman_file; } ||
|
|
|
|
_arch_incomp 'o owns' || _arch_incomp 'u upgrades' ||
|
|
|
|
_pacman_pkg Qq;;
|
2007-02-16 14:37:00 -05:00
|
|
|
S)
|
2010-05-18 18:26:47 -04:00
|
|
|
{ _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
|
|
|
|
{ _arch_incomp 'l list' && _pacman_pkg Sl sort; } ||
|
|
|
|
_pacman_pkg Slq;;
|
|
|
|
U)
|
|
|
|
_pacman_file;;
|
|
|
|
esac
|
2007-02-16 14:37:00 -05:00
|
|
|
fi
|
2010-05-18 18:26:47 -04:00
|
|
|
true
|
2007-02-16 14:37:00 -05:00
|
|
|
}
|
2010-05-18 18:26:47 -04:00
|
|
|
|
2010-06-21 22:30:44 -04:00
|
|
|
if [[ $(type -t compopt) = "builtin" ]]; then
|
|
|
|
_pacman_file() {
|
|
|
|
compopt -o filenames; _filedir 'pkg.tar.*'
|
|
|
|
}
|
|
|
|
complete -F _pacman -o default pacman
|
|
|
|
else
|
|
|
|
_pacman_file() {
|
|
|
|
_filedir 'pkg.tar.*'
|
|
|
|
}
|
|
|
|
complete -F _pacman -o filenames -o default pacman
|
|
|
|
fi
|
|
|
|
|
2010-05-18 18:26:47 -04:00
|
|
|
complete -F _makepkg -o default makepkg
|
2011-09-25 14:32:15 -04:00
|
|
|
complete -F _pacman_key -o default pacman-key
|
2010-05-18 18:26:47 -04:00
|
|
|
|
|
|
|
# ex:et ts=2 sw=2 ft=sh
|