zsh 19 KB

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