fish 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. # vim:fdm=marker foldlevel=0 tabstop=2 shiftwidth=2 filetype=fish
  2. # Original Author for pacman: Giorgio Lando <patroclo7@gmail.com>
  3. # Updated for yay by jguer
  4. set -l progname yay
  5. # Yay constants
  6. set -l listall "(yay -Pc)"
  7. set -l listpacman "(__fish_print_packages)"
  8. set -l yayspecific '__fish_contains_opt -s Y yay'
  9. set -l webspecific '__fish_contains_opt -s W web'
  10. set -l show '__fish_contains_opt -s P show'
  11. set -l getpkgbuild '__fish_contains_opt -s G getpkgbuild'
  12. # Pacman constants
  13. set -l listinstalled "(pacman -Q | string replace ' ' \t)"
  14. set -l listrepos "(__fish_print_pacman_repos)"
  15. set -l listgroups "(pacman -Sg)\t'Package Group'"
  16. set -l noopt 'not __fish_contains_opt -s S -s D -s Q -s R -s U -s T -s F -s Y -s W -s P -s G database query sync remove upgrade deptest files show getpkgbuild web yay'
  17. set -l database '__fish_contains_opt -s D database'
  18. set -l query '__fish_contains_opt -s Q query'
  19. set -l remove '__fish_contains_opt -s R remove'
  20. set -l sync '__fish_contains_opt -s S sync'
  21. set -l upgrade '__fish_contains_opt -s U upgrade'
  22. set -l files '__fish_contains_opt -s F files'
  23. complete -c $progname -e
  24. complete -c $progname -f
  25. # HACK: We only need these two to coerce fish to stop file completion and complete options
  26. complete -c $progname -n "$noopt" -a "-D" -d "Modify the package database"
  27. complete -c $progname -n "$noopt" -a "-Q" -d "Query the package database"
  28. # Primary operations
  29. complete -c $progname -s D -f -l database -n "$noopt" -d 'Modify the package database'
  30. complete -c $progname -s Q -f -l query -n "$noopt" -d 'Query the package database'
  31. complete -c $progname -s R -f -l remove -n "$noopt" -d 'Remove packages from the system'
  32. complete -c $progname -s S -f -l sync -n "$noopt" -d 'Synchronize packages'
  33. complete -c $progname -s T -f -l deptest -n "$noopt" -d 'Check dependencies'
  34. complete -c $progname -s U -l upgrade -n "$noopt" -d 'Upgrade or add a local package'
  35. complete -c $progname -s F -f -l files -n "$noopt" -d 'Query the files database'
  36. complete -c $progname -s V -f -l version -d 'Display version and exit'
  37. complete -c $progname -s h -f -l help -d 'Display help'
  38. # General options
  39. # Only offer these once a command has been given so they get prominent display
  40. complete -c $progname -n "not $noopt" -s b -l dbpath -d 'Alternate database location' -xa "(__fish_complete_directories)"
  41. complete -c $progname -n "not $noopt" -s r -l root -d 'Alternate installation root' -xa "(__fish_complete_directories)"
  42. complete -c $progname -n "not $noopt" -s v -l verbose -d 'Output more status messages' -f
  43. complete -c $progname -n "not $noopt" -l arch -d 'Alternate architecture' -f
  44. complete -c $progname -n "not $noopt" -l cachedir -d 'Alternate package cache location' -xa "(__fish_complete_directories)"
  45. complete -c $progname -n "not $noopt" -l color -d 'Colorize the output' -fa '{auto,always,never}'
  46. complete -c $progname -n "not $noopt" -l config -d 'Alternate config file' -rF
  47. complete -c $progname -n "not $noopt" -l confirm -d 'Always ask for confirmation' -f
  48. complete -c $progname -n "not $noopt" -l debug -d 'Display debug messages' -f
  49. complete -c $progname -n "not $noopt" -l disable-download-timeout -d 'Use relaxed timeouts for download' -f
  50. complete -c $progname -n "not $noopt" -l gpgdir -d 'Alternate home directory for GnuPG' -xa "(__fish_complete_directories)"
  51. complete -c $progname -n "not $noopt" -l hookdir -d 'Alternate hook location' -xa "(__fish_complete_directories)"
  52. complete -c $progname -n "not $noopt" -l logfile -d 'Alternate log file'
  53. complete -c $progname -n "not $noopt" -l noconfirm -d 'Bypass any confirmation' -f
  54. complete -c $progname -n "not $noopt" -l sysroot -d 'Operate on a mounted guest system (root-only)' -xa "(__fish_complete_directories)"
  55. # File, query, sync options (files, query, sync)
  56. for condition in files query sync
  57. complete -c $progname -n "$$condition" -s q -l quiet -d 'Show less information' -f
  58. end
  59. # Transaction options (sync, remove, upgrade)
  60. for condition in sync remove upgrade
  61. complete -c $progname -n "$$condition" -s d -l nodeps -d 'Skip [all] dependency checks' -f
  62. complete -c $progname -n "$$condition" -s p -l print -d 'Dry run, only print targets' -f
  63. complete -c $progname -n "$$condition" -l assume-installed -d 'Add a virtual package to satisfy dependencies' -f
  64. complete -c $progname -n "$$condition" -l dbonly -d 'Modify database entry only' -f
  65. complete -c $progname -n "$$condition" -l noprogressbar -d 'Do not display progress bar' -f
  66. complete -c $progname -n "$$condition" -l noscriptlet -d 'Do not execute install script' -f
  67. complete -c $progname -n "$$condition" -l print-format -d 'Specify printf-like format' -x
  68. end
  69. # File and query options (files, query)
  70. for condition in files query
  71. complete -c $progname -n "$$condition" -s l -l list -d 'List the files owned by PACKAGE' -f
  72. end
  73. # File and sync options (files, sync)
  74. for condition in files sync
  75. complete -c $progname -n "$$condition" -s y -l refresh -d 'Download fresh package databases [force]' -f
  76. end
  77. # Query and sync options (query, sync)
  78. for condition in query sync
  79. complete -c $progname -n "$$condition" -s g -l groups -d 'Display members of [all] package GROUP' -xa "$listgroups"
  80. end
  81. # Sync and upgrade options (sync, upgrade)
  82. for condition in sync upgrade
  83. complete -c $progname -n "$$condition" -l asdeps -d 'Install packages as non-explicitly installed' -f
  84. complete -c $progname -n "$$condition" -l asexplicit -d 'Install packages as explicitly installed' -f
  85. complete -c $progname -n "$$condition" -l ignore -d 'Ignore a package upgrade (can be used more than once)' -xa "$listall"
  86. complete -c $progname -n "$$condition" -l ignoregroup -d 'Ignore a group upgrade (can be used more than once)' -xa "$listgroups"
  87. complete -c $progname -n "$$condition" -l needed -d 'Do not reinstall up to date packages' -f
  88. complete -c $progname -n "$$condition" -l overwrite -d 'Overwrite conflicting files (can be used more than once)' -rF
  89. end
  90. # Database options
  91. set -l has_db_opt '__fish_contains_opt asdeps asexplicit check -s k'
  92. complete -c $progname -n "$database; and not $has_db_opt" -s k -l check -d 'Check database validity'
  93. complete -c $progname -n "$database" -s q -l quite -d 'Suppress output of success messages' -f
  94. complete -c $progname -n "$database; and not $has_db_opt" -l asdeps -d 'Mark PACKAGE as dependency' -x
  95. complete -c $progname -n "$database; and not $has_db_opt" -l asexplicit -d 'Mark PACKAGE as explicitly installed' -x
  96. complete -c $progname -n "$has_db_opt; and $database" -xa "$listinstalled"
  97. # File options - since pacman 5
  98. complete -c $progname -n "$files" -s x -l regex -d 'Interpret each query as a regular expression' -f
  99. complete -c $progname -n "$files" -l machinereadable -d 'Print each match in a machine readable output format' -f
  100. complete -c $progname -n "$files" -d Package -xa "$listpacman"
  101. # Query options
  102. complete -c $progname -n "$query" -s c -l changelog -d 'View the change log of PACKAGE' -f
  103. complete -c $progname -n "$query" -s d -l deps -d 'List only non-explicit packages (dependencies)' -f
  104. complete -c $progname -n "$query" -s e -l explicit -d 'List only explicitly installed packages' -f
  105. complete -c $progname -n "$query" -s i -l info -d 'View PACKAGE [backup files] information' -f
  106. complete -c $progname -n "$query" -s k -l check -d 'Check that PACKAGE files exist' -f
  107. complete -c $progname -n "$query" -s m -l foreign -d 'List installed packages not found in sync database' -f
  108. complete -c $progname -n "$query" -s n -l native -d 'list installed packages only found in sync database' -f
  109. complete -c $progname -n "$query" -s o -l owns -d 'Query the package that owns FILE' -rF
  110. complete -c $progname -n "$query" -s p -l file -d 'Query a package file instead of the database' -rF
  111. complete -c $progname -n "$query" -s s -l search -d 'Search locally-installed packages for regexp' -f
  112. complete -c $progname -n "$query" -s t -l unrequired -d 'List only unrequired packages [and optdepends]' -f
  113. complete -c $progname -n "$query" -s u -l upgrades -d 'List only out-of-date packages' -f
  114. complete -c $progname -n "$query" -d 'Installed package' -xa "$listinstalled"
  115. # Remove options
  116. complete -c $progname -n "$remove" -s c -l cascade -d 'Also remove packages depending on PACKAGE' -f
  117. complete -c $progname -n "$remove" -s n -l nosave -d 'Ignore file backup designations' -f
  118. complete -c $progname -n "$remove" -s s -l recursive -d 'Also remove dependencies of PACKAGE' -f
  119. complete -c $progname -n "$remove" -s u -l unneeded -d 'Only remove targets not required by PACKAGE' -f
  120. complete -c $progname -n "$remove" -d 'Installed package' -xa "$listinstalled"
  121. # Sync options
  122. complete -c $progname -n "$sync" -s c -l clean -d 'Remove [all] packages from cache' -f
  123. complete -c $progname -n "$sync" -s i -l info -d 'View PACKAGE [extended] information' -f
  124. complete -c $progname -n "$sync" -s l -l list -d 'List all packages in REPOSITORY' -xa "$listrepos"
  125. complete -c $progname -n "$sync" -s s -l search -d 'Search remote repositories for regexp' -f
  126. complete -c $progname -n "$sync" -s u -l sysupgrade -d 'Upgrade all packages that are out of date'
  127. complete -c $progname -n "$sync" -s w -l downloadonly -d 'Only download the target packages'
  128. complete -c $progname -n "$sync" -xa "$listall $listgroups"
  129. # Upgrade options
  130. # Theoretically, pacman reads packages in all formats that libarchive supports
  131. # In practice, it's going to be tar.xz, tar.gz, tar.zst, or just pkg.tar (uncompressed pkg)
  132. complete -c $progname -n "$upgrade" -xa '(__fish_complete_suffix pkg.tar.zst; __fish_complete_suffix pkg.tar.xz; __fish_complete_suffix pkg.tar.gz; __fish_complete_suffix pkg.tar;)' -d 'Package file'
  133. # Yay operations
  134. complete -c $progname -s Y -f -l yay -n "$noopt" -d 'Yay specific operations'
  135. complete -c $progname -s P -f -l show -n "$noopt" -d 'Print information'
  136. complete -c $progname -s G -f -l getpkgbuild -n "$noopt" -d 'Get PKGBUILD from ABS or AUR'
  137. complete -c $progname -s W -f -l web -n "$noopt" -d 'Web operations'
  138. # Web options
  139. complete -c $progname -n "$webspecific" -s v -l vote -d 'Vote for AUR packages' -f
  140. complete -c $progname -n "$webspecific" -s u -l unvote -d 'Unvote for AUR packages' -f
  141. complete -c $progname -n "$webspecific" -xa "$listall"
  142. # New options
  143. complete -c $progname -n "not $noopt" -s a -l aur -d 'Assume targets are from the AUR' -f
  144. complete -c $progname -n "not $noopt" -s N -l repo -d 'Assume targets are from the repositories' -f
  145. # Yay options
  146. complete -c $progname -n "$yayspecific" -s c -l clean -d 'Remove unneeded dependencies' -f
  147. complete -c $progname -n "$yayspecific" -l gendb -d 'Generate development package DB' -f
  148. # Show options
  149. complete -c $progname -n "$show" -s c -l complete -d 'Print a list of all AUR and repo packages' -f
  150. #complete -c $progname -n "$show" -s f -l fish -d 'During complete adjust the output for the fish shell' -f
  151. complete -c $progname -n "$show" -s d -l defaultconfig -d 'Print default yay configuration' -f
  152. complete -c $progname -n "$show" -s g -l currentconfig -d 'Print current yay configuration' -f
  153. complete -c $progname -n "$show" -s s -l stats -d 'Display system package statistics' -f
  154. complete -c $progname -n "$show" -s w -l news -d 'Print arch news' -f
  155. complete -c $progname -n "$show" -s q -l quiet -d 'Do not print news description' -f
  156. # Getpkgbuild options
  157. complete -c $progname -n "$getpkgbuild" -s f -l force -d 'Force download for existing ABS packages' -f
  158. complete -c $progname -n "$getpkgbuild" -xa "$listall"
  159. complete -c $progname -n "$getpkgbuild" -s p -l print -d 'Print pkgbuild of packages' -f
  160. # Permanent configuration settings
  161. complete -c $progname -n "not $noopt" -l save -d 'Save current arguments to yay permanent configuration' -f
  162. complete -c $progname -n "not $noopt" -l aururl -d 'Set an alternative AUR URL' -f
  163. complete -c $progname -n "not $noopt" -l aurrpcurl -d 'Set an alternative URL for the AUR /rpc endpoint' -f
  164. complete -c $progname -n "not $noopt" -l builddir -d 'Directory to use for Building AUR Packages' -r
  165. complete -c $progname -n "not $noopt" -l editor -d 'Editor to use' -f
  166. complete -c $progname -n "not $noopt" -l editorflags -d 'Editor flags to use' -f
  167. complete -c $progname -n "not $noopt" -l makepkg -d 'Makepkg command to use' -f
  168. complete -c $progname -n "not $noopt" -l pacman -d 'Pacman command to use' -f
  169. complete -c $progname -n "not $noopt" -l tar -d 'Tar command to use' -f
  170. complete -c $progname -n "not $noopt" -l git -d 'Git command to use' -f
  171. complete -c $progname -n "not $noopt" -l gpg -d 'Gpg command to use' -f
  172. complete -c $progname -n "not $noopt" -l config -d 'The pacman config file to use' -r
  173. complete -c $progname -n "not $noopt" -l makepkgconf -d 'Use custom makepkg.conf location' -r
  174. complete -c $progname -n "not $noopt" -l nomakepkgconf -d 'Use default makepkg.conf' -f
  175. complete -c $progname -n "not $noopt" -l requestsplitn -d 'Max amount of packages to query per AUR request' -f
  176. complete -c $progname -n "not $noopt" -l completioninterval -d 'Refresh interval for completion cache' -f
  177. complete -c $progname -n "not $noopt" -l sortby -d 'Sort AUR results by a specific field during search' -xa "{votes,popularity,id,baseid,name,base,submitted,modified}"
  178. complete -c $progname -n "not $noopt" -l searchby -d 'Search for AUR packages by querying the specified field' -xa "{name,name-desc,maintainer,depends,checkdepends,makedepends,optdepends}"
  179. complete -c $progname -n "not $noopt" -l answerclean -d 'Set a predetermined answer for the clean build menu' -xa "{All,None,Installed,NotInstalled}"
  180. complete -c $progname -n "not $noopt" -l answerdiff -d 'Set a predetermined answer for the edit diff menu' -xa "{All,None,Installed,NotInstalled}"
  181. complete -c $progname -n "not $noopt" -l answeredit -d 'Set a predetermined answer for the edit pkgbuild menu' -xa "{All,None,Installed,NotInstalled}"
  182. complete -c $progname -n "not $noopt" -l answerupgrade -d 'Set a predetermined answer for the upgrade menu' -f
  183. complete -c $progname -n "not $noopt" -l noanswerclean -d 'Unset the answer for the clean build menu' -f
  184. complete -c $progname -n "not $noopt" -l noanswerdiff -d 'Unset the answer for the diff menu' -f
  185. complete -c $progname -n "not $noopt" -l noansweredit -d 'Unset the answer for the edit pkgbuild menu' -f
  186. complete -c $progname -n "not $noopt" -l noanswerupgrade -d 'Unset the answer for the upgrade menu' -f
  187. complete -c $progname -n "not $noopt" -l cleanmenu -d 'Give the option to clean build PKGBUILDS' -f
  188. complete -c $progname -n "not $noopt" -l diffmenu -d 'Give the option to show diffs for build files' -f
  189. complete -c $progname -n "not $noopt" -l editmenu -d 'Give the option to edit/view PKGBUILDS' -f
  190. complete -c $progname -n "not $noopt" -l askremovemake -d 'Ask to remove make deps after install' -f
  191. complete -c $progname -n "not $noopt" -l askyesremovemake -d 'Ask to remove make deps after install(with "Y" as default)' -f
  192. complete -c $progname -n "not $noopt" -l removemake -d 'Remove make deps after install' -f
  193. complete -c $progname -n "not $noopt" -l noremovemake -d 'Do not remove make deps after install' -f
  194. complete -c $progname -n "not $noopt" -l topdown -d 'Shows repository packages first and then aur' -f
  195. complete -c $progname -n "not $noopt" -l bottomup -d 'Shows aur packages first and then repository' -f
  196. complete -c $progname -n "not $noopt" -l singlelineresults -d 'List each search result on its own line' -f
  197. complete -c $progname -n "not $noopt" -l doublelineresults -d 'List each search result on two lines, like pacman' -f
  198. complete -c $progname -n "not $noopt" -l devel -d 'Check -git/-svn/-hg development version' -f
  199. complete -c $progname -n "not $noopt" -l cleanafter -d 'Clean package sources after successful build' -f
  200. complete -c $progname -n "not $noopt" -l keepsrc -d 'Keep pkg/ and src/ after building packages' -f
  201. complete -c $progname -n "not $noopt" -l timeupdate -d 'Check package modification date and version' -f
  202. complete -c $progname -n "not $noopt" -l redownload -d 'Redownload PKGBUILD of package even if up-to-date' -f
  203. complete -c $progname -n "not $noopt" -l redownloadall -d 'Redownload PKGBUILD of package and deps even if up-to-date' -f
  204. complete -c $progname -n "not $noopt" -l noredownload -d 'Do not redownload up-to-date PKGBUILDs' -f
  205. complete -c $progname -n "not $noopt" -l provides -d 'Look for matching providers when searching for packages' -f
  206. complete -c $progname -n "not $noopt" -l pgpfetch -d 'Prompt to import PGP keys from PKGBUILDs' -f
  207. complete -c $progname -n "not $noopt" -l useask -d 'Automatically resolve conflicts using pacmans ask flag' -f
  208. complete -c $progname -n "not $noopt" -l combinedupgrade -d 'Refresh then perform the repo and AUR upgrade together' -f
  209. complete -c $progname -n "not $noopt" -l batchinstall -d 'Build multiple AUR packages then install them together' -f
  210. complete -c $progname -n "not $noopt" -l rebuild -d 'Always build target packages' -f
  211. complete -c $progname -n "not $noopt" -l rebuildall -d 'Always build all AUR packages' -f
  212. complete -c $progname -n "not $noopt" -l rebuildtree -d 'Always build all AUR packages even if installed' -f
  213. complete -c $progname -n "not $noopt" -l norebuild -d 'Skip package build if in cache and up to date' -f
  214. complete -c $progname -n "not $noopt" -l mflags -d 'Pass the following options to makepkg' -f
  215. complete -c $progname -n "not $noopt" -l gpgflags -d 'Pass the following options to gpg' -f
  216. complete -c $progname -n "not $noopt" -l sudoloop -d 'Loop sudo calls in the background to avoid timeout' -f