zsh 20 KB

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