fish 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. complete -e -c $progname
  6. complete -c $progname -f
  7. set -l listinstalled "(pacman -Q | string replace ' ' \t)"
  8. # This might be an issue if another package manager is also installed (e.g. for containers)
  9. set -l listall "(yay -Pc)"
  10. set -l listrepos "(__fish_print_pacman_repos)"
  11. set -l listgroups "(pacman -Sg)\t'Package Group'"
  12. set -l listpacman "(__fish_print_packages)"
  13. set -l noopt 'not __fish_contains_opt -s Y -s G -s V -s P -s S -s D -s Q -s R -s U -s T -s F database query sync remove upgrade deptest files'
  14. set -l database '__fish_contains_opt -s D database'
  15. set -l getpkgbuild '__fish_contains_opt -s G getpkgbuild'
  16. set -l show '__fish_contains_opt -s P show'
  17. set -l query '__fish_contains_opt -s Q query'
  18. set -l remove '__fish_contains_opt -s R remove'
  19. set -l sync '__fish_contains_opt -s S sync'
  20. set -l upgrade '__fish_contains_opt -s U upgrade'
  21. set -l files '__fish_contains_opt -s F files'
  22. set -l yayspecific '__fish_contains_opt -s Y yay'
  23. # HACK: We only need these two to coerce fish to stop file completion and complete options
  24. # complete -c $progname -n $noopt -a "-D" -d "Modify the package database"
  25. # complete -c $progname -n $noopt -a "-Q" -d "Query the package database"
  26. # Primary operations
  27. complete -c $progname -s D -f -l database -n $noopt -d 'Modify the package database'
  28. complete -c $progname -s F -f -l files -n $noopt -d 'Query the files database'
  29. complete -c $progname -s G -f -l getpkgbuild -n $noopt -d 'Get PKGBUILD from ABS or AUR'
  30. complete -c $progname -s P -f -l show -n $noopt -d 'Print information'
  31. complete -c $progname -s Q -f -l query -n $noopt -d 'Query the package database'
  32. complete -c $progname -s R -f -l remove -n $noopt -d 'Remove packages from the system'
  33. complete -c $progname -s S -f -l sync -n $noopt -d 'Synchronize packages'
  34. complete -c $progname -s T -f -l deptest -n $noopt -d 'Check if dependencies are installed'
  35. complete -c $progname -s U -f -l upgrade -n $noopt -d 'Upgrade or add a local package'
  36. complete -c $progname -s Y -f -l yay -n $noopt -d 'Yay specific operations'
  37. complete -c $progname -s V -f -l version -n $noopt -d 'Display version and exit'
  38. complete -c $progname -s h -f -l help -n $noopt -d 'Display help'
  39. # General options
  40. # Only offer these once a command has been given so they get prominent display
  41. complete -c $progname -n "not $noopt" -s a -l aur -d 'Assume targets are from the repositories'
  42. complete -c $progname -n "not $noopt" -l repo -d 'Assume targets are from the AUR'
  43. complete -c $progname -n "not $noopt" -s b -l aururl -d 'Set an alternative AUR URL' -f
  44. complete -c $progname -n "not $noopt" -s b -l dbpath -d 'Alternative database location' -xa '(__fish_complete_directories)'
  45. complete -c $progname -n "not $noopt" -s r -l root -d 'Alternative installation root'
  46. complete -c $progname -n "not $noopt" -s v -l verbose -d 'Output more status messages'
  47. complete -c $progname -n "not $noopt" -s h -l help -d 'Display syntax for the given operation'
  48. complete -c $progname -n "not $noopt" -l arch -d 'Alternate architecture' -f
  49. complete -c $progname -n "not $noopt" -l cachedir -d 'Alternative package cache location'
  50. complete -c $progname -n "not $noopt" -l color -d 'Colorize the output'
  51. complete -c $progname -n "not $noopt" -l config -d 'Alternate config file'
  52. complete -c $progname -n "not $noopt" -l debug -d 'Display debug messages' -f
  53. complete -c $progname -n "not $noopt" -l gpgdir -d 'GPG directory to verify signatures'
  54. complete -c $progname -n "not $noopt" -l hookdir -d 'Hook file directory'
  55. complete -c $progname -n "not $noopt" -l logfile -d 'Specify alternative log file'
  56. complete -c $progname -n "not $noopt" -l noconfirm -d 'Bypass any question' -f
  57. complete -c $progname -n "not $noopt" -l topdown -d 'Shows repository packages first and then aur' -f
  58. complete -c $progname -n "not $noopt" -l bottomup -d 'Shows aur packages first and then repository' -f
  59. complete -c $progname -n "not $noopt" -l devel -d 'Check -git/-svn/-hg development version' -f
  60. complete -c $progname -n "not $noopt" -l nodevel -d 'Disable development version checking' -f
  61. complete -c $progname -n "not $noopt" -l cleanafter -d 'Clean package sources after successful build' -f
  62. complete -c $progname -n "not $noopt" -l nocleanafter -d 'Disable package sources cleaning' -f
  63. complete -c $progname -n "not $noopt" -l timeupdate -d 'Check package modification date and version' -f
  64. complete -c $progname -n "not $noopt" -l notimeupdate -d 'Check only package version change' -f
  65. complete -c $progname -n "not $noopt" -l save -d 'Save current arguments to yay permanent configuration' -f
  66. complete -c $progname -n "not $noopt" -l mflags -d 'Pass the following options to makepkg' -f
  67. complete -c $progname -n "not $noopt" -l gpgflags -d 'Pass the following options to gpg' -f
  68. complete -c $progname -n "not $noopt" -l buildir -d 'Specify the build directory' -f
  69. complete -c $progname -n "not $noopt" -l editor -d 'Editor to use' -f
  70. complete -c $progname -n "not $noopt" -l editorflags -d 'Editor flags to use' -f
  71. complete -c $progname -n "not $noopt" -l makepkg -d 'Makepkg command to use' -f
  72. complete -c $progname -n "not $noopt" -l pacman -d 'Pacman command to use' -f
  73. complete -c $progname -n "not $noopt" -l tar -d 'Tar command to use' -f
  74. complete -c $progname -n "not $noopt" -l git -d 'Git command to use' -f
  75. complete -c $progname -n "not $noopt" -l gpg -d 'Gpg command to use' -f
  76. complete -c $progname -n "not $noopt" -l requestsplitn -d 'Max amount of packages to query per AUR request' -f
  77. complete -c $progname -n "not $noopt" -l sudoloop -d 'Loop sudo calls in the background to avoid timeout' -f
  78. complete -c $progname -n "not $noopt" -l nosudoloop -d 'Do not loop sudo calls in the background' -f
  79. complete -c $progname -n "not $noopt" -l redownload -d 'Redownload PKGBUILD of package even if up-to-date' -f
  80. complete -c $progname -n "not $noopt" -l noredownload -d 'Do not redownload up-to-date PKGBUILDs' -f
  81. complete -c $progname -n "not $noopt" -l redownloadall -d 'Redownload PKGBUILD of package and deps even if up-to-date' -f
  82. complete -c $progname -n "not $noopt" -l rebuild -d 'Always build target packages' -f
  83. complete -c $progname -n "not $noopt" -l rebuildall -d 'Always build all AUR packages' -f
  84. complete -c $progname -n "not $noopt" -l rebuildtree -d 'Always build all AUR packages even if installed' -f
  85. complete -c $progname -n "not $noopt" -l norebuild -d 'Skip package build if in cache and up to date' -f
  86. complete -c $progname -n "not $noopt" -l sortby -d 'Sort AUR results by a specific field during search' -f
  87. complete -c $progname -n "not $noopt" -l answerclean -d 'Set a predetermined answer for the clean build menu' -f
  88. complete -c $progname -n "not $noopt" -l answeredit -d 'Set a predetermined answer for the edit pkgbuild menu' -f
  89. complete -c $progname -n "not $noopt" -l answerupgrade -d 'Set a predetermined answer for the upgrade menu' -f
  90. complete -c $progname -n "not $noopt" -l noanswerclean -d 'Unset the answer for the clean build menu' -f
  91. complete -c $progname -n "not $noopt" -l noansweredit -d 'Unset the answer for the edit pkgbuild menu' -f
  92. complete -c $progname -n "not $noopt" -l noanswerupgrade -d 'Unset the answer for the upgrade menu' -f
  93. complete -c $progname -n "not $noopt" -l cleanmenu -d 'Give the option to clean build PKGBUILDS' -f
  94. complete -c $progname -n "not $noopt" -l diffmenu -d 'Give the option to show diffs for build files' -f
  95. complete -c $progname -n "not $noopt" -l editmenu -d 'Give the option to edit/view PKGBUILDS' -f
  96. complete -c $progname -n "not $noopt" -l upgrademenu -d 'Show a detailed list of updates with the option to skip any' -f
  97. complete -c $progname -n "not $noopt" -l nocleanmenu -d 'Do not clean build PKGBUILDS' -f
  98. complete -c $progname -n "not $noopt" -l nodiffmenu -d 'Do not show diffs for build files' -f
  99. complete -c $progname -n "not $noopt" -l noeditmenu -d 'Do not edit/view PKGBUILDS' -f
  100. complete -c $progname -n "not $noopt" -l noupgrademenu -d 'Do not show the upgrade menu' -f
  101. complete -c $progname -n "not $noopt" -l provides -d 'Look for matching providers when searching for packages'
  102. complete -c $progname -n "not $noopt" -l noprovides -d 'Just look for packages by pkgname'
  103. complete -c $progname -n "not $noopt" -l pgpfetch -d 'Prompt to import PGP keys from PKGBUILDs'
  104. complete -c $progname -n "not $noopt" -l nopgpfetch -d 'Do not prompt to import PGP keys'
  105. # Post V7.887
  106. complete -c $progname -n "not $noopt" -l useask -d 'Automatically resolve conflicts using pacmans ask flag'
  107. complete -c $progname -n "not $noopt" -l nouseask -d 'Confirm conflicts manually during the install'
  108. complete -c $progname -n "not $noopt" -l combinedupgrade -d 'Refresh then perform the repo and AUR upgrade together'
  109. complete -c $progname -n "not $noopt" -l nocombinedupgrade -d 'Perform the repo upgrade and AUR upgrade separately'
  110. #Post V8.976
  111. complete -c $progname -n "not $noopt" -l nomakepkgconf -d 'Use default makepkg.conf'
  112. complete -c $progname -n "not $noopt" -l makepkgconf -d 'Use custom makepkg.conf location'
  113. complete -c $progname -n "not $noopt" -l removemake -d 'Remove make deps after install'
  114. complete -c $progname -n "not $noopt" -l askremovemake -d 'Ask to remove make deps after install'
  115. complete -c $progname -n "not $noopt" -l noremovemake -d 'Do not remove make deps after install'
  116. complete -c $progname -n "not $noopt" -l completioninterval -d 'Refresh interval for completion cache'
  117. # Yay options
  118. complete -c $progname -n $yayspecific -s c -l clean -d 'Remove unneeded dependencies' -f
  119. complete -c $progname -n $yayspecific -l gendb -d 'Generate development package DB' -f
  120. # Show options
  121. complete -c $progname -n $show -s d -l defaultconfig -d 'Print default yay configuration' -f
  122. complete -c $progname -n $show -s g -l currentconfig -d 'Print current yay configuration' -f
  123. complete -c $progname -n $show -s s -l stats -d 'Display system package statistics' -f
  124. complete -c $progname -n $show -s w -l news -d 'Print arch news'
  125. complete -c $progname -n $show -s q -l quiet -d 'Do not print news description'
  126. # Getpkgbuild options
  127. complete -c $progname -n $getpkgbuild -s f -l force -d 'Force download for existing tar packages' -f
  128. # Transaction options (sync, remove, upgrade)
  129. for condition in sync remove upgrade
  130. complete -c $progname -n $$condition -s d -l nodeps -d 'Skip [all] dependency checks' -f
  131. complete -c $progname -n $$condition -l dbonly -d 'Modify database entry only' -f
  132. complete -c $progname -n $$condition -l noprogressbar -d 'Do not display progress bar' -f
  133. complete -c $progname -n $$condition -l noscriptlet -d 'Do not execute install script' -f
  134. complete -c $progname -n $$condition -s p -l print -d 'Dry run, only print targets' -f
  135. complete -c $progname -n $$condition -l print-format -x -d 'Specify printf-like format' -f
  136. end
  137. # Database and upgrade options (database, sync, upgrade)
  138. for condition in database sync upgrade
  139. complete -c $progname -n $$condition -l asdeps -d 'Mark PACKAGE as dependency' -f
  140. complete -c $progname -n $$condition -l asexplicit -d 'Mark PACKAGE as explicitly installed' -f
  141. end
  142. # Upgrade options (sync, upgrade)
  143. for condition in sync upgrade
  144. complete -c $progname -n $$condition -l overwrite -d 'overwrite conflicting files (can be used more than once)'
  145. complete -c $progname -n $$condition -l ignore -d 'Ignore upgrade of PACKAGE' -xa "$listinstalled" -f
  146. complete -c $progname -n $$condition -l ignoregroup -d 'Ignore upgrade of GROUP' -xa "$listgroups" -f
  147. complete -c $progname -n $$condition -l needed -d 'Do not reinstall up-to-date targets' -f
  148. complete -c $progname -n $$condition -l recursive -d 'Recursively reinstall all dependencies' -f
  149. end
  150. # Query and sync options
  151. for condition in query sync
  152. complete -c $progname -n $$condition -s g -l groups -d 'Display all packages in GROUP' -xa "$listgroups" -f
  153. complete -c $progname -n $$condition -s i -l info -d 'Display information on PACKAGE' -f
  154. complete -c $progname -n $$condition -s q -l quiet -d 'Show less information' -f
  155. complete -c $progname -n $$condition -s s -l search -r -d 'Search packages for regexp' -f
  156. end
  157. # Get PKGBUILD options
  158. complete -c $progname -n "$getpkgbuild" -xa "$listall"
  159. # Query options
  160. complete -c $progname -n $query -s c -l changelog -d 'View the change log of PACKAGE' -f
  161. complete -c $progname -n $query -s d -l deps -d 'List only non-explicit packages (dependencies)' -f
  162. complete -c $progname -n $query -s e -l explicit -d 'List only explicitly installed packages' -f
  163. complete -c $progname -n $query -s k -l check -d 'Check if all files owned by PACKAGE are present' -f
  164. complete -c $progname -n $query -s l -l list -d 'List all files owned by PACKAGE' -f
  165. complete -c $progname -n $query -s m -l foreign -d 'List all packages not in the database' -f
  166. complete -c $progname -n $query -s o -l owns -r -d 'Search for the package that owns FILE'
  167. complete -c $progname -n $query -s p -l file -d 'Apply the query to a package file, not package' -xa '' -f
  168. complete -c $progname -n $query -s t -l unrequired -d 'List only unrequired packages' -f
  169. complete -c $progname -n $query -s u -l upgrades -d 'List only out-of-date packages' -f
  170. complete -c $progname -n "$query" -d 'Installed package' -xa $listinstalled -f
  171. # Remove options
  172. complete -c $progname -n $remove -s c -l cascade -d 'Also remove packages depending on PACKAGE' -f
  173. complete -c $progname -n $remove -s n -l nosave -d 'Ignore file backup designations' -f
  174. complete -c $progname -n $remove -s s -l recursive -d 'Also remove dependencies of PACKAGE' -f
  175. complete -c $progname -n $remove -s u -l unneeded -d 'Only remove targets not required by PACKAGE' -f
  176. complete -c $progname -n "$remove" -d 'Installed package' -xa $listinstalled -f
  177. # Sync options
  178. complete -c $progname -n $sync -s c -l clean -d 'Remove [all] packages from cache'
  179. complete -c $progname -n $sync -s l -l list -xa "$listrepos" -d 'List all packages in REPOSITORY'
  180. complete -c $progname -n "$sync; and not __fish_contains_opt -s u sysupgrade" -s u -l sysupgrade -d 'Upgrade all packages that are out of date'
  181. complete -c $progname -n "$sync; and __fish_contains_opt -s u sysupgrade" -s u -l sysupgrade -d 'Also downgrade packages'
  182. complete -c $progname -n $sync -s w -l downloadonly -d 'Only download the target packages'
  183. complete -c $progname -n $sync -s y -l refresh -d 'Download fresh copy of the package list'
  184. complete -c $progname -n "$sync" -xa "$listall $listgroups"
  185. # Database options
  186. set -l has_db_opt '__fish_contains_opt asdeps asexplicit'
  187. complete -c $progname -n "$database; and not $has_db_opt" -xa --asdeps -d 'Mark PACKAGE as dependency'
  188. complete -c $progname -n "$database; and not $has_db_opt" -xa --asexplicit -d 'Mark PACKAGE as explicitly installed'
  189. complete -c $progname -n "$database; and not $has_db_opt" -s k -l check -d 'Check database validity'
  190. complete -c $progname -n "$has_db_opt; and $database" -xa "$listinstalled"
  191. # File options - since pacman 5
  192. set -l has_file_opt '__fish_contains_opt list search -s l -s s'
  193. complete -c $progname -n "$files; and not $has_file_opt" -xa --list -d 'List files owned by given packages'
  194. complete -c $progname -n "$files; and not $has_file_opt" -xa -l -d 'List files owned by given packages'
  195. complete -c $progname -n "$files" -s y -l refresh -d 'Refresh the files database' -f
  196. complete -c $progname -n "$files" -s l -l list -d 'List files owned by given packages' -xa $listpacman
  197. complete -c $progname -n "$files" -s x -l regex -d 'Interpret each query as a regular expression' -f
  198. complete -c $progname -n "$files" -s q -l quiet -d 'Show less information' -f
  199. complete -c $progname -n "$files" -l machinereadable -d 'Print each match in a machine readable output format' -f
  200. # Upgrade options
  201. # Theoretically, pacman reads packages in all formats that libarchive supports
  202. # In practice, it's going to be tar.xz, tar.gz or tar.zst
  203. # Using "pkg.tar.*" here would change __fish_complete_suffix's descriptions to "unknown"
  204. complete -c $progname -n "$upgrade" -xa '(__fish_complete_suffix .pkg.tar\{,.xz,.gz,.zst\})' -d 'Package file'