zsh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. #compdef yay
  2. # vim:tabstop=2 shiftwidth=2 filetype=zsh
  3. typeset -A opt_args
  4. setopt extendedglob
  5. # options for passing to _arguments: main pacman commands
  6. _pacman_opts_commands=(
  7. {-D,--database}'[Modify database]'
  8. {-F,--files}'[Query the files database]'
  9. {-G,--getpkgbuild}'[Get PKGBUILD from ABS or AUR]'
  10. {-Q,--query}'[Query the package database]'
  11. {-R,--remove}'[Remove a package from the system]'
  12. {-P,--show}'[Print yay information]'
  13. {-S,--sync}'[Synchronize packages]'
  14. {-T,--deptest}'[Check if dependencies are installed]'
  15. {-U,--upgrade}'[Upgrade a package]'
  16. {-Y,--yay}'[Yay specific options]'
  17. {-W,--web}'[web options]'
  18. {-V,--version}'[Display version and exit]'
  19. '(-h --help)'{-h,--help}'[Display usage]'
  20. )
  21. # options for passing to _arguments: options common to all commands
  22. _pacman_opts_common=(
  23. '--repo[Assume targets are from the repositories]'
  24. {-a,--aur}'[Assume targets are from the AUR]'
  25. '--aururl[Set an alternative AUR URL]:url'
  26. '--aurrpcurl[Set an alternative URL for the AUR /rpc endpoint]:url'
  27. '--arch[Set an alternate architecture]'
  28. {-b,--dbpath}'[Alternate database location]:database_location:_files -/'
  29. '--color[colorize the output]:color options:(always never auto)'
  30. {-h,--help}'[Display syntax for the given operation]'
  31. {-r,--root}'[Set alternate installation root]:installation root:_files -/'
  32. {-v,--verbose}'[Be more verbose]'
  33. '--cachedir[Alternate package cache location]:cache_location:_files -/'
  34. '--config[An alternate configuration file]:config file:_files'
  35. '--makepkgconf[makepkg.conf file to use]:config file:_files'
  36. '--nomakepkgconf[Use the default makepkg.conf]'
  37. '--requestsplitn[Max amount of packages to query per AUR request]:number'
  38. '--completioninterval[Time in days to refresh completion cache]:number'
  39. '--confirm[Always ask for confirmation]'
  40. '--debug[Display debug messages]'
  41. '--gpgdir[Set an alternate directory for GnuPG (instead of /etc/pacman.d/gnupg)]: :_files -/'
  42. '--hookdir[Set an alternate hook location]: :_files -/'
  43. '--logfile[An alternate log file]:config file:_files'
  44. '--noconfirm[Do not ask for confirmation]'
  45. '--noprogressbar[Do not show a progress bar when downloading files]'
  46. '--noscriptlet[Do not execute the install scriptlet if one exists]'
  47. '--save[Causes config options to be saved back to the config file]'
  48. '--builddir[Directory to use for building AUR Packages]:build dir:_files -/'
  49. '--editor[Editor to use when editing PKGBUILDs]:editor:_files'
  50. '--editorflags[Flags to pass to editor]'
  51. '--makepkg[makepkg command to use]:makepkg:_files'
  52. '--pacman[pacman command to use]:pacman:_files'
  53. '--git[git command to use]:git:_files'
  54. '--gpg[gpg command to use]:gpg:_files'
  55. '--sortby[Sort AUR results by a specific field during search]:sortby options:(votes popularity id baseid name base submitted modified)'
  56. '--answerclean[Set a predetermined answer for the clean build menu]:answer'
  57. '--answerdiff[Set a predetermined answer for the diff menu]:answer'
  58. '--answeredit[Set a predetermined answer for the edit pkgbuild menu]:answer'
  59. '--answerupgrade[Set a predetermined answer for the upgrade menu]:answer'
  60. '--noanswerclean[Unset the answer for the clean build menu]'
  61. '--noanswerdiff[Unset the answer for the diff menu]'
  62. '--noansweredit[Unset the answer for the edit pkgbuild menu]'
  63. '--noanswerupgrade[Unset the answer for the upgrade menu]'
  64. '--cleanmenu[Give the option to clean build PKGBUILDS]'
  65. '--diffmenu[Give the option to show diffs for build files]'
  66. '--editmenu[Give the option to edit/view PKGBUILDS]'
  67. "--nocleanmenu[Don't clean build PKGBUILDS]"
  68. "--nodiffmenu[Don't show diffs for build files]"
  69. "--noeditmenu[Don't edit/view PKGBUILDS]"
  70. "--askremovemake[Ask to remove makedepends after install]"
  71. "--removemake[Remove makedepends after install]"
  72. "--noremovemake[Don't remove makedepends after install]"
  73. '--bottomup[Show AUR packages first]'
  74. '--topdown[Show repository packages first]'
  75. '--singlelineresults[List each search result on its own line]'
  76. '--doublelineresults[List each search result on two lines, like pacman]'
  77. '--devel[Check -git/-svn/-hg development version]'
  78. '--nodevel[Disable development version checking]'
  79. '--cleanafter[Clean package sources after successful build]'
  80. '--nocleanafter[Disable package sources cleaning after successful build]'
  81. '--timeupdate[Check packages modification date and version]'
  82. '--notimeupdate[Check only package version change]'
  83. '--redownload[Always download pkgbuilds of targets]'
  84. '--redownloadall[Always download pkgbuilds of all AUR packages]'
  85. '--noredownload[Skip pkgbuild download if in cache and up to date]'
  86. '--rebuild[Always build target packages]'
  87. '--rebuildall[Always build all AUR packages]'
  88. '--provides[Look for matching providers when searching for packages]'
  89. '--noprovides[Just look for packages by pkgname]'
  90. '--pgpfetch[Prompt to import PGP keys from PKGBUILDs]'
  91. "--nopgpfetch[Don't prompt to import PGP keys]"
  92. "--useask[Automatically resolve conflicts using pacman's ask flag]"
  93. '--nouseask[Confirm conflicts manually during the install]'
  94. '--combinedupgrade[Refresh then perform the repo and AUR upgrade together]'
  95. '--nocombinedupgrade[Perform the repo upgrade and AUR upgrade separately]'
  96. '--rebuildtree[Always build all AUR packages even if installed]'
  97. '--norebuild[Skip package build if in cache and up to date]'
  98. '--mflags[Pass arguments to makepkg]:mflags'
  99. '--gpgflags[Pass arguments to gpg]:gpgflags'
  100. '--sudoloop[Loop sudo calls in the background to avoid timeout]'
  101. '--nosudoloop[Do not loop sudo calls in the background]'
  102. '--searchby[Search for packages using a specified field]'
  103. '--sortby[Sort AUR results by a specific field during search]'
  104. '--batchinstall[Build multiple AUR packages then install them together]'
  105. '--nobatchinstall[Build and install each AUR package one by one]'
  106. )
  107. # options for passing to _arguments: options for --upgrade commands
  108. _pacman_opts_pkgfile=(
  109. '*-d[Skip dependency checks]'
  110. '*--nodeps[Skip dependency checks]'
  111. '*--assume-installed[Add virtual package to satisfy dependencies]'
  112. '--dbonly[Only remove database entry, do not remove files]'
  113. '--overwrite[Overwrite conflicting files]:file:_files -g "*"'
  114. '--needed[Do not reinstall up to date packages]'
  115. '--asdeps[mark packages as non-explicitly installed]'
  116. '--asexplicit[mark packages as explicitly installed]'
  117. {-p,--print}'[Only print the targets instead of performing the operation]'
  118. '*--ignore[Ignore a package upgrade]:package: _pacman_completions_all_packages'
  119. '*--ignoregroup[Ignore a group upgrade]:package group:_pacman_completions_all_groups'
  120. '--print-format[Specify how the targets should be printed]'
  121. '*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
  122. )
  123. # options for passing to _arguments: subactions for --query command
  124. _pacman_opts_query_actions=(
  125. '(-Q --query)'{-Q,--query}
  126. {-g,--groups}'[View all members of a package group]:*:package groups:->query_group'
  127. {-o,--owns}'[Query the package that owns a file]:file:_files'
  128. {-p,--file}'[Package file to query]:*:package file:->query_file'
  129. {-s,--search}'[Search package names and descriptions]:*:search text:->query_search'
  130. )
  131. # options for passing to _arguments: options for --query and subcommands
  132. _pacman_opts_query_modifiers=(
  133. {-c,--changelog}'[List package changelog]'
  134. {-d,--deps}'[List packages installed as dependencies]'
  135. {-e,--explicit}'[List packages explicitly installed]'
  136. {\*-i,\*--info}'[View package information]'
  137. {\*-k,\*--check}'[Check package files]'
  138. {-l,--list}'[List package contents]'
  139. {-m,--foreign}'[List installed packages not found in sync db(s)]'
  140. {-n,--native}'[List installed packages found in sync db(s)]'
  141. {-q,--quiet}'[Show less information for query and search]'
  142. {-t,--unrequired}'[List packages not required by any package]'
  143. {-u,--upgrades}'[List packages that can be upgraded]'
  144. )
  145. # -Y
  146. _pacman_opts_yay_modifiers=(
  147. {-c,--clean}'[Remove unneeded dependencies]'
  148. '--gendb[Generates development package DB used for updating]'
  149. )
  150. # -G
  151. _pacman_opts_getpkgbuild_modifiers=(
  152. {-f,--force}'[Force download for existing ABS packages]'
  153. {-p,--print}'[Print PKGBUILDs]:package:_pacman_completions_all_packages'
  154. )
  155. # -W
  156. _pacman_opts_web_modifiers=(
  157. {-u,--unvote}'[Unvote AUR package]:package:_pacman_completions_all_packages'
  158. {-v,--vote}'[Vote AUR package]:package:_pacman_completions_all_packages'
  159. )
  160. # -P
  161. _pacman_opts_print_modifiers=(
  162. {-c,--complete}'[Used for completions]'
  163. {-d,--defaultconfig}'[Print default yay configuration]'
  164. {-g,--config}'[Print current yay configuration]'
  165. {-n,--numberupgrades}'[Print number of updates]'
  166. {-s,--stats}'[Display system package statistics]'
  167. {-u,--upgrades}'[Print update list]'
  168. {-w,--news}'[Print arch news]'
  169. )
  170. # options for passing to _arguments: options for --remove command
  171. _pacman_opts_remove=(
  172. {-c,--cascade}'[Remove all dependent packages]'
  173. {-d,--nodeps}'[Skip dependency checks]'
  174. '*--assume-installed[Add virtual package to satisfy dependencies]'
  175. {-n,--nosave}'[Remove protected configuration files]'
  176. {-p,--print}'[Only print the targets instead of performing the operation]'
  177. {\*-s,\*--recursive}'[Remove dependencies not required by other packages]'
  178. {-u,--unneeded}'[Remove unneeded packages]'
  179. '--dbonly[Only remove database entry, do not remove files]'
  180. '--print-format[Specify how the targets should be printed]'
  181. '*:installed package:_pacman_completions_installed_packages'
  182. )
  183. _pacman_opts_database=(
  184. '--asdeps[mark packages as non-explicitly installed]'
  185. '--asexplicit[mark packages as explicitly installed]'
  186. '*:installed package:_pacman_completions_installed_packages'
  187. )
  188. _pacman_opts_files=(
  189. {-l,--list}'[List the files owned by the queried package]:package:_pacman_completions_all_packages'
  190. {-x,--regex}'[Enable searching using regular expressions]:regex:'
  191. {-y,--refresh}'[Download fresh files databases from the server]'
  192. '--machinereadable[Produce machine-readable output]'
  193. {-q,--quiet}'[Show less information for query and search]'
  194. )
  195. # options for passing to _arguments: options for --sync command
  196. _pacman_opts_sync_actions=(
  197. '(-S --sync)'{-S,--sync}
  198. {\*-c,\*--clean}'[Remove old packages from cache]:\*:clean:->sync_clean'
  199. {-g,--groups}'[View all members of a package group]:*:package groups:->sync_group'
  200. {-s,--search}'[Search package names and descriptions]:*:search text:->sync_search'
  201. '--dbonly[Only remove database entry, do not remove files]'
  202. '--needed[Do not reinstall up to date packages]'
  203. '--recursive[Reinstall all dependencies of target packages]'
  204. )
  205. # options for passing to _arguments: options for --sync command
  206. _pacman_opts_sync_modifiers=(
  207. {\*-d,\*--nodeps}'[Skip dependency checks]'
  208. '*--assume-installed[Add virtual package to satisfy dependencies]'
  209. {\*-i,\*--info}'[View package information]'
  210. {-l,--list}'[List all packages in a repository]'
  211. {-p,--print}'[Print download URIs for each package to be installed]'
  212. {-q,--quiet}'[Show less information for query and search]'
  213. {\*-u,\*--sysupgrade}'[Upgrade all out-of-date packages]'
  214. {-w,--downloadonly}'[Download packages only]'
  215. {\*-y,\*--refresh}'[Download fresh package databases]'
  216. '*--ignore[Ignore a package upgrade]:package: _pacman_completions_all_packages'
  217. '*--ignoregroup[Ignore a group upgrade]:package group:_pacman_completions_all_groups'
  218. '--asdeps[Install packages as non-explicitly installed]'
  219. '--asexplicit[Install packages as explicitly installed]'
  220. '--overwrite[Overwrite conflicting files]:files:_files'
  221. '--print-format[Specify how the targets should be printed]'
  222. )
  223. # handles --help subcommand
  224. _pacman_action_help() {
  225. _arguments -s : \
  226. "$_pacman_opts_commands[@]"
  227. }
  228. # handles cases where no subcommand has yet been given
  229. _pacman_action_none() {
  230. _arguments -s : \
  231. "$_pacman_opts_commands[@]"
  232. }
  233. # handles --query subcommand
  234. _pacman_action_query() {
  235. local context state line
  236. typeset -A opt_args
  237. case $state in
  238. query_file)
  239. _arguments -s : \
  240. "$_pacman_opts_common[@]" \
  241. "$_pacman_opts_query_modifiers[@]" \
  242. '*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
  243. ;;
  244. query_group)
  245. _arguments -s : \
  246. "$_pacman_opts_common[@]" \
  247. "$_pacman_opts_query_modifiers[@]" \
  248. '*:groups:_pacman_completions_installed_groups'
  249. ;;
  250. query_owner)
  251. _arguments -s : \
  252. "$_pacman_opts_common[@]" \
  253. "$_pacman_opts_query_modifiers[@]" \
  254. '*:file:_files'
  255. ;;
  256. query_search)
  257. _arguments -s : \
  258. "$_pacman_opts_common[@]" \
  259. "$_pacman_opts_query_modifiers[@]" \
  260. '*:search text: '
  261. ;;
  262. *)
  263. _arguments -s : \
  264. "$_pacman_opts_common[@]" \
  265. "$_pacman_opts_query_actions[@]" \
  266. "$_pacman_opts_query_modifiers[@]" \
  267. '*:package:_pacman_completions_installed_packages'
  268. ;;
  269. esac
  270. }
  271. # handles --remove subcommand
  272. _pacman_action_remove() {
  273. _arguments -s : \
  274. '(--remove -R)'{-R,--remove} \
  275. "$_pacman_opts_common[@]" \
  276. "$_pacman_opts_remove[@]"
  277. }
  278. # handles --database subcommand
  279. _pacman_action_database() {
  280. _arguments -s : \
  281. '(--database -D)'{-D,--database} \
  282. "$_pacman_opts_common[@]" \
  283. "$_pacman_opts_database[@]"
  284. }
  285. # handles --files subcommand
  286. _pacman_action_files() {
  287. _arguments -s : \
  288. '(--files -F)'{-F,--files} \
  289. "$_pacman_opts_common[@]" \
  290. "$_pacman_opts_files[@]"
  291. }
  292. _pacman_action_deptest () {
  293. _arguments -s : \
  294. '(--deptest)-T' \
  295. "$_pacman_opts_common[@]" \
  296. ":packages:_pacman_all_packages"
  297. }
  298. # handles --sync subcommand
  299. _pacman_action_sync() {
  300. local context state line
  301. typeset -A opt_args
  302. if (( $+words[(r)--clean] )); then
  303. state=sync_clean
  304. elif (( $+words[(r)--groups] )); then
  305. state=sync_group
  306. elif (( $+words[(r)--search] )); then
  307. state=sync_search
  308. fi
  309. case $state in
  310. sync_clean)
  311. _arguments -s : \
  312. {\*-c,\*--clean}'[Remove old packages from cache]' \
  313. "$_pacman_opts_common[@]" \
  314. "$_pacman_opts_sync_modifiers[@]"
  315. ;;
  316. sync_group)
  317. _arguments -s : \
  318. "$_pacman_opts_common[@]" \
  319. "$_pacman_opts_sync_modifiers[@]" \
  320. '(-g --group)'{-g,--groups} \
  321. '*:package group:_pacman_completions_all_groups'
  322. ;;
  323. sync_search)
  324. _arguments -s : \
  325. "$_pacman_opts_common[@]" \
  326. "$_pacman_opts_sync_modifiers[@]" \
  327. '*:search text: '
  328. ;;
  329. *)
  330. _arguments -s : \
  331. "$_pacman_opts_common[@]" \
  332. "$_pacman_opts_sync_actions[@]" \
  333. "$_pacman_opts_sync_modifiers[@]" \
  334. '*:package:_pacman_completions_all_packages'
  335. ;;
  336. esac
  337. }
  338. # handles --upgrade subcommand
  339. _pacman_action_upgrade() {
  340. _arguments -s : \
  341. '(-U --upgrade)'{-U,--upgrade} \
  342. "$_pacman_opts_common[@]" \
  343. "$_pacman_opts_pkgfile[@]"
  344. }
  345. # handles --version subcommand
  346. _pacman_action_version() {
  347. # no further arguments
  348. return 0
  349. }
  350. # provides completions for package groups
  351. _pacman_completions_all_groups() {
  352. local -a cmd groups
  353. _pacman_get_command
  354. groups=( $(_call_program groups $cmd[@] -Sg) )
  355. typeset -U groups
  356. if [[ ${words[CURRENT-1]} == '--ignoregroup' ]]; then
  357. _sequence compadd -S ',' "$@" -a groups
  358. else
  359. compadd "$@" -a groups
  360. fi
  361. }
  362. # provides completions for packages available from repositories
  363. # these can be specified as either 'package' or 'repository/package'
  364. _pacman_completions_all_packages() {
  365. local -a seq sep cmd packages repositories packages_long
  366. if [[ ${words[CURRENT-1]} == '--ignore' ]]; then
  367. seq='_sequence'
  368. sep=(-S ',')
  369. else
  370. seq=
  371. sep=()
  372. fi
  373. if compset -P1 '*/*'; then
  374. packages=( $(_call_program packages yay -Pc ${words[CURRENT]%/*}) )
  375. typeset -U packages
  376. ${seq} _wanted repo_packages expl "repository/package" compadd ${sep[@]} ${(@)packages}
  377. else
  378. packages=( $(_call_program packages yay -Pc ) )
  379. typeset -U packages
  380. ${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}"
  381. repositories=($(pacman-conf --repo-list))
  382. typeset -U repositories
  383. _wanted repo_packages expl "repository/package" compadd -S "/" $repositories
  384. fi
  385. }
  386. # provides completions for package groups
  387. _pacman_completions_installed_groups() {
  388. local -a cmd groups
  389. _pacman_get_command
  390. groups=(${(o)${(f)"$(_call_program groups $cmd[@] -Qg)"}% *})
  391. typeset -U groups
  392. compadd "$@" -a groups
  393. }
  394. # provides completions for installed packages
  395. _pacman_completions_installed_packages() {
  396. local -a cmd packages packages_long
  397. packages_long=(/var/lib/pacman/local/*(/))
  398. packages=( ${${packages_long#/var/lib/pacman/local/}%-*-*} )
  399. compadd "$@" -a packages
  400. }
  401. _pacman_all_packages() {
  402. _alternative : \
  403. 'localpkgs:local packages:_pacman_completions_installed_packages' \
  404. 'repopkgs:repository packages:_pacman_completions_all_packages'
  405. }
  406. # provides completions for repository names
  407. _pacman_completions_repositories() {
  408. local -a cmd repositories
  409. repositories=($(pacman-conf --repo-list))
  410. # Uniq the array
  411. typeset -U repositories
  412. compadd "$@" -a repositories
  413. }
  414. # builds command for invoking pacman in a _call_program command - extracts
  415. # relevant options already specified (config file, etc)
  416. # $cmd must be declared by calling function
  417. _pacman_get_command() {
  418. # this is mostly nicked from _perforce
  419. cmd=( "pacman" "2>/dev/null")
  420. integer i
  421. for (( i = 2; i < CURRENT - 1; i++ )); do
  422. if [[ ${words[i]} = "--config" || ${words[i]} = "--root" ]]; then
  423. cmd+=( ${words[i,i+1]} )
  424. fi
  425. done
  426. }
  427. # main dispatcher
  428. _pacman_zsh_comp() {
  429. local -a args cmds;
  430. local tmp
  431. args=( ${${${(M)words:#-*}#-}:#-*} )
  432. for tmp in $words; do
  433. cmds+=("${${_pacman_opts_commands[(r)*$tmp\[*]%%\[*}#*\)}")
  434. done
  435. case $args in #$words[2] in
  436. h*)
  437. if (( ${(c)#args} <= 1 && ${(w)#cmds} <= 1 )); then
  438. _pacman_action_help
  439. else
  440. _message "no more arguments"
  441. fi
  442. ;;
  443. *h*)
  444. _message "no more arguments"
  445. ;;
  446. D*)
  447. _pacman_action_database
  448. ;;
  449. F*)
  450. _pacman_action_files
  451. ;;
  452. Q*g*) # ipkg groups
  453. _arguments -s : \
  454. "$_pacman_opts_common[@]" \
  455. "$_pacman_opts_query_modifiers[@]" \
  456. '*:groups:_pacman_completions_installed_groups'
  457. ;;
  458. Q*o*) # file
  459. _arguments -s : \
  460. "$_pacman_opts_common[@]" \
  461. "$_pacman_opts_query_modifiers[@]" \
  462. '*:package file:_files'
  463. ;;
  464. Q*p*) # file *.pkg.tar*
  465. _arguments -s : \
  466. "$_pacman_opts_common[@]" \
  467. "$_pacman_opts_query_modifiers[@]" \
  468. '*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
  469. ;;
  470. Q*)
  471. _pacman_action_query
  472. ;;
  473. P*)
  474. _arguments -s : \
  475. '-P' \
  476. "$_pacman_opts_print_modifiers[@]"
  477. ;;
  478. W*)
  479. _arguments -s : \
  480. '-W' \
  481. "$_pacman_opts_web_modifiers[@]"
  482. ;;
  483. R*)
  484. _pacman_action_remove
  485. ;;
  486. S*c*) # no completion
  487. _arguments -s : \
  488. '(-c --clean)'{\*-c,\*--clean}'[Remove all files from the cache]' \
  489. "$_pacman_opts_common[@]"
  490. ;;
  491. S*l*) # repos
  492. _arguments -s : \
  493. "$_pacman_opts_common[@]" \
  494. "$_pacman_opts_sync_modifiers[@]" \
  495. '*:package repo:_pacman_completions_repositories' \
  496. ;;
  497. S*g*) # pkg groups
  498. _arguments -s : \
  499. "$_pacman_opts_common[@]" \
  500. "$_pacman_opts_sync_modifiers[@]" \
  501. '*:package group:_pacman_completions_all_groups'
  502. ;;
  503. S*s*)
  504. _arguments -s : \
  505. "$_pacman_opts_common[@]" \
  506. "$_pacman_opts_sync_modifiers[@]" \
  507. '*:search text: '
  508. ;;
  509. S*)
  510. _pacman_action_sync
  511. ;;
  512. T*)
  513. _pacman_action_deptest
  514. ;;
  515. U*)
  516. _pacman_action_upgrade
  517. ;;
  518. V*)
  519. _pacman_action_version
  520. ;;
  521. Y*)
  522. _arguments -s : \
  523. '-Y' \
  524. "$_pacman_opts_yay_modifiers[@]"
  525. ;;
  526. G*)
  527. _arguments -s : \
  528. '-G' \
  529. "$_pacman_opts_getpkgbuild_modifiers[@]"
  530. ;;
  531. *)
  532. case ${(M)words:#--*} in
  533. *--help*)
  534. if (( ${(w)#cmds} == 1 )); then
  535. _pacman_action_help
  536. else
  537. return 0;
  538. fi
  539. ;;
  540. *--sync*)
  541. _pacman_action_sync
  542. ;;
  543. *--query*)
  544. _pacman_action_query
  545. ;;
  546. *--remove*)
  547. _pacman_action_remove
  548. ;;
  549. *--deptest*)
  550. _pacman_action_deptest
  551. ;;
  552. *--database*)
  553. _pacman_action_database
  554. ;;
  555. *--files*)
  556. _pacman_action_files
  557. ;;
  558. *--version*)
  559. _pacman_action_version
  560. ;;
  561. *--upgrade*)
  562. _pacman_action_upgrade
  563. ;;
  564. *)
  565. _pacman_action_none
  566. ;;
  567. esac
  568. ;;
  569. esac
  570. }
  571. _pacman_comp() {
  572. case "$service" in
  573. yay)
  574. _pacman_zsh_comp "$@"
  575. ;;
  576. *)
  577. _message "Error"
  578. ;;
  579. esac
  580. }
  581. _pacman_comp "$@"