2016-12-02 22:21:27 +01:00
|
|
|
# This file is in the public domain.
|
|
|
|
|
|
|
|
_arch_compgen() {
|
|
|
|
local i r
|
|
|
|
COMPREPLY=($(compgen -W '$*' -- "$cur"))
|
2019-10-25 13:01:33 +02:00
|
|
|
for ((i = 1; i < ${#COMP_WORDS[@]} - 1; i++)); do
|
2016-12-02 22:21:27 +01:00
|
|
|
for r in ${!COMPREPLY[@]}; do
|
2019-10-25 13:01:33 +02:00
|
|
|
if [[ ${COMP_WORDS[i]} == ${COMPREPLY[r]} ]]; then
|
|
|
|
unset 'COMPREPLY[r]'
|
|
|
|
break
|
2016-12-02 22:21:27 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
_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
|
|
|
|
}
|
|
|
|
|
|
|
|
_arch_incomp() {
|
2019-10-25 13:01:33 +02:00
|
|
|
local r="[[:space:]]-(-${1#* }[[:space:]]|[[:alnum:]_]*${1% *})"
|
|
|
|
[[ $COMP_LINE =~ $r ]]
|
2016-12-02 22:21:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_pacman_pkg() {
|
|
|
|
_arch_compgen "$(
|
|
|
|
if [[ $2 ]]; then
|
|
|
|
\pacman -$1 2>/dev/null | \cut -d' ' -f1 | \sort -u
|
|
|
|
else
|
|
|
|
\pacman -$1 2>/dev/null
|
|
|
|
fi
|
|
|
|
)"
|
|
|
|
}
|
|
|
|
|
2018-08-06 00:01:09 +02:00
|
|
|
_yay_pkg() {
|
2019-11-04 18:32:52 +01:00
|
|
|
[ -z "$cur" ] && _pacman_pkg Slq && return
|
2018-08-06 00:01:09 +02:00
|
|
|
_arch_compgen "$(yay -Pc)"
|
|
|
|
}
|
2018-06-12 20:43:04 +02:00
|
|
|
|
2018-08-06 00:01:09 +02:00
|
|
|
_pacman_repo_list() {
|
|
|
|
_arch_compgen "$(pacman-conf --repo-list)"
|
|
|
|
}
|
2018-06-12 20:43:04 +02:00
|
|
|
|
2017-04-10 00:00:04 +02:00
|
|
|
_yay() {
|
2019-10-25 13:01:33 +02:00
|
|
|
compopt -o default
|
2018-08-06 00:01:09 +02:00
|
|
|
local common core cur database files prev query remove sync upgrade o
|
2018-08-30 17:07:45 +02:00
|
|
|
local yays show getpkgbuild
|
2019-10-25 13:01:33 +02:00
|
|
|
local cur prev words cword
|
|
|
|
|
|
|
|
_init_completion || return
|
2016-12-02 22:21:27 +01:00
|
|
|
database=('asdeps asexplicit')
|
2019-11-04 18:32:52 +01:00
|
|
|
files=('list machinereadable refresh regex' 'l x y')
|
2018-08-06 00:01:09 +02:00
|
|
|
query=('changelog check deps explicit file foreign groups info list native owns
|
|
|
|
search unrequired upgrades' 'c e g i k l m n o p s t u')
|
2016-12-02 22:21:27 +01:00
|
|
|
remove=('cascade dbonly nodeps assume-installed nosave print recursive unneeded' 'c n p s u')
|
2019-11-04 18:32:52 +01:00
|
|
|
sync=('asdeps asexplicit clean dbonly downloadonly overwrite groups ignore ignoregroup
|
2016-12-02 22:21:27 +01:00
|
|
|
info list needed nodeps assume-installed print refresh recursive search sysupgrade'
|
2019-10-25 13:01:33 +02:00
|
|
|
'c g i l p s u w y')
|
2019-11-04 18:32:52 +01:00
|
|
|
upgrade=('asdeps asexplicit overwrite needed nodeps assume-installed print recursive' 'p')
|
2016-12-02 22:21:27 +01:00
|
|
|
core=('database files help query remove sync upgrade version' 'D F Q R S U V h')
|
|
|
|
|
2018-08-06 00:01:09 +02:00
|
|
|
##yay stuff
|
2019-10-25 13:01:33 +02:00
|
|
|
common=('arch cachedir color config confirm dbpath debug gpgdir help hookdir logfile
|
|
|
|
noconfirm noprogressbar noscriptlet quiet root verbose
|
2019-11-04 18:32:52 +01:00
|
|
|
makepkg pacman git gpg gpgflags config requestsplitn sudoloop nosudoloop
|
2019-10-25 13:01:33 +02:00
|
|
|
redownload noredownload redownloadall rebuild rebuildall rebuildtree norebuild
|
|
|
|
sortby answerclean answerdiff answeredit answerupgrade noanswerclean noanswerdiff
|
|
|
|
noansweredit noanswerupgrade cleanmenu diffmenu editmenu upgrademenu cleanafter nocleanafter
|
|
|
|
nocleanmenu nodiffmenu noupgrademenu provides noprovides pgpfetch nopgpfetch
|
|
|
|
useask nouseask combinedupgrade nocombinedupgrade aur repo makepkgconf
|
|
|
|
nomakepkgconf askremovemake removemake noremovemake completioninterval aururl
|
|
|
|
searchby batchinstall nobatchinstall'
|
|
|
|
'b d h q r v')
|
2018-08-06 00:01:09 +02:00
|
|
|
yays=('clean gendb' 'c')
|
2018-08-30 17:07:45 +02:00
|
|
|
show=('complete defaultconfig currentconfig stats news' 'c d g s w')
|
|
|
|
getpkgbuild=('force' 'f')
|
2018-08-06 00:01:09 +02:00
|
|
|
|
2018-08-30 17:07:45 +02:00
|
|
|
for o in 'D database' 'F files' 'Q query' 'R remove' 'S sync' 'U upgrade' 'Y yays' 'P show' 'G getpkgbuild'; do
|
2016-12-02 22:21:27 +01:00
|
|
|
_arch_incomp "$o" && break
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
_arch_ptr2comp core
|
2019-10-25 13:01:33 +02:00
|
|
|
elif [[ ! $prev =~ ^-[[:alnum:]_]*[Vbhr] && ! $prev == --@(cachedir|color|config|dbpath|help|hookdir|gpgdir|logfile|root|version) ]]; then
|
|
|
|
[[ $cur == -* ]] && _arch_ptr2comp ${o#* } common ||
|
2016-12-02 22:21:27 +01:00
|
|
|
case ${o% *} in
|
2019-10-25 13:01:33 +02:00
|
|
|
D | R)
|
|
|
|
_pacman_pkg Qq
|
|
|
|
;;
|
2016-12-02 22:21:27 +01:00
|
|
|
F)
|
2019-10-25 13:01:33 +02:00
|
|
|
{ _arch_incomp 'l list' && _pacman_pkg Slq; } ||
|
|
|
|
_arch_incomp 'o owns' ||
|
|
|
|
compopt +o default
|
|
|
|
;;
|
2016-12-02 22:21:27 +01:00
|
|
|
Q)
|
2019-10-25 13:01:33 +02:00
|
|
|
{ _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||
|
|
|
|
{ _arch_incomp 'p file' && _pacman_file; } ||
|
|
|
|
{ _arch_incomp 's search' && compopt +o default; } ||
|
|
|
|
{ _arch_incomp 'u upgrades' && compopt +o default; } ||
|
|
|
|
_arch_incomp 'o owns' ||
|
|
|
|
_pacman_pkg Qq
|
|
|
|
;;
|
2016-12-02 22:21:27 +01:00
|
|
|
S)
|
2019-10-25 13:01:33 +02:00
|
|
|
{ _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
|
|
|
|
{ _arch_incomp 'l list' && _pacman_repo_list; } ||
|
|
|
|
{ _arch_incomp 's search' && compopt +o default; } ||
|
|
|
|
_yay_pkg
|
|
|
|
;;
|
2016-12-02 22:21:27 +01:00
|
|
|
U)
|
2019-10-25 13:01:33 +02:00
|
|
|
_pacman_file
|
|
|
|
;;
|
|
|
|
G)
|
|
|
|
_yay_pkg
|
|
|
|
;;
|
2016-12-02 22:21:27 +01:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
_pacman_file() {
|
2019-10-25 13:01:33 +02:00
|
|
|
compopt -o filenames
|
|
|
|
_filedir 'pkg.tar*'
|
2016-12-02 22:21:27 +01:00
|
|
|
}
|
|
|
|
|
2019-10-25 13:01:33 +02:00
|
|
|
complete -F _yay yay
|
2016-12-02 22:21:27 +01:00
|
|
|
|
|
|
|
# ex:et ts=2 sw=2 ft=sh
|