zsh 20 KB

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