mirror of
https://github.com/Jguer/yay
synced 2024-10-31 04:12:51 +00:00
Fixes to completions, added -G completions to fish. Closes #2
This commit is contained in:
parent
771410bc03
commit
2bdaec82bc
2 changed files with 74 additions and 13 deletions
5
yay.fish
5
yay.fish
|
@ -13,6 +13,7 @@ set -l listgroups "(pacman -Sg)\t'Package Group'"
|
||||||
|
|
||||||
set -l noopt 'not __fish_contains_opt -s S -s D -s Q -s R -s U -s T -s F database query sync remove upgrade deptest files'
|
set -l noopt 'not __fish_contains_opt -s S -s D -s Q -s R -s U -s T -s F database query sync remove upgrade deptest files'
|
||||||
set -l database '__fish_contains_opt -s D database'
|
set -l database '__fish_contains_opt -s D database'
|
||||||
|
set -l getpkgbuild '__fish_contains_opt -s G getpkgbuild'
|
||||||
set -l query '__fish_contains_opt -s Q query'
|
set -l query '__fish_contains_opt -s Q query'
|
||||||
set -l remove '__fish_contains_opt -s R remove'
|
set -l remove '__fish_contains_opt -s R remove'
|
||||||
set -l sync '__fish_contains_opt -s S sync'
|
set -l sync '__fish_contains_opt -s S sync'
|
||||||
|
@ -28,6 +29,7 @@ complete -c $progname -n $noopt -a "-Q" -d "Query the package database"
|
||||||
# Primary operations
|
# Primary operations
|
||||||
complete -c $progname -s D -f -l database -n $noopt -d 'Modify the package database'
|
complete -c $progname -s D -f -l database -n $noopt -d 'Modify the package database'
|
||||||
complete -c $progname -s Q -f -l query -n $noopt -d 'Query the package database'
|
complete -c $progname -s Q -f -l query -n $noopt -d 'Query the package database'
|
||||||
|
complete -c $progname -s G -f -l getpkgbuild -n $noopt -d 'Get PKGBUILD from ABS or AUR'
|
||||||
complete -c $progname -s R -f -l remove -n $noopt -d 'Remove packages from the system'
|
complete -c $progname -s R -f -l remove -n $noopt -d 'Remove packages from the system'
|
||||||
complete -c $progname -s S -f -l sync -n $noopt -d 'Synchronize packages'
|
complete -c $progname -s S -f -l sync -n $noopt -d 'Synchronize packages'
|
||||||
complete -c $progname -s T -f -l deptest -n $noopt -d 'Check if dependencies are installed'
|
complete -c $progname -s T -f -l deptest -n $noopt -d 'Check if dependencies are installed'
|
||||||
|
@ -85,6 +87,9 @@ for condition in query sync
|
||||||
complete -c $progname -n $$condition -s s -l search -r -d 'Search packages for regexp' -f
|
complete -c $progname -n $$condition -s s -l search -r -d 'Search packages for regexp' -f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get PKGBUILD options
|
||||||
|
complete -c $progname -n "$getpkgbuild" -xa "$listall"
|
||||||
|
|
||||||
# Query options
|
# Query options
|
||||||
complete -c $progname -n $query -s c -l changelog -d 'View the change log of PACKAGE' -f
|
complete -c $progname -n $query -s c -l changelog -d 'View the change log of PACKAGE' -f
|
||||||
complete -c $progname -n $query -s d -l deps -d 'List only non-explicit packages (dependencies)' -f
|
complete -c $progname -n $query -s d -l deps -d 'List only non-explicit packages (dependencies)' -f
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#compdef yay yay.static=yay
|
#compdef yay
|
||||||
|
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
setopt extendedglob
|
setopt extendedglob
|
||||||
|
@ -6,7 +6,8 @@ setopt extendedglob
|
||||||
# options for passing to _arguments: main pacman commands
|
# options for passing to _arguments: main pacman commands
|
||||||
_pacman_opts_commands=(
|
_pacman_opts_commands=(
|
||||||
{-D,--database}'[Modify database]'
|
{-D,--database}'[Modify database]'
|
||||||
{-G,--getpkgfile}'[Get PKGBUILD from ABS or AUR]'
|
{-F,--files}'[Query the files database]'
|
||||||
|
{-G,--getpkgbuild}'[Get PKGBUILD from ABS or AUR]'
|
||||||
{-Q,--query}'[Query the package database]'
|
{-Q,--query}'[Query the package database]'
|
||||||
{-R,--remove}'[Remove a package from the system]'
|
{-R,--remove}'[Remove a package from the system]'
|
||||||
{-S,--sync}'[Synchronize packages]'
|
{-S,--sync}'[Synchronize packages]'
|
||||||
|
@ -18,29 +19,40 @@ _pacman_opts_commands=(
|
||||||
|
|
||||||
# options for passing to _arguments: options common to all commands
|
# options for passing to _arguments: options common to all commands
|
||||||
_pacman_opts_common=(
|
_pacman_opts_common=(
|
||||||
|
'--arch[Set an alternate architecture]'
|
||||||
{-b,--dbpath}'[Alternate database location]:database_location:_files -/'
|
{-b,--dbpath}'[Alternate database location]:database_location:_files -/'
|
||||||
'--color[colorize the output]:color options:(always never auto)'
|
'--color[colorize the output]:color options:(always never auto)'
|
||||||
{-h,--help}'[Display syntax for the given operation]'
|
{-h,--help}'[Display syntax for the given operation]'
|
||||||
{-r,--root}'[Set alternate installation root]:installation root:_files -/'
|
{-r,--root}'[Set alternate installation root]:installation root:_files -/'
|
||||||
{-v,--verbose}'[Be more verbose]'
|
{-v,--verbose}'[Be more verbose]'
|
||||||
'--topdown[shows repositorys packages first and then aurs]'
|
|
||||||
'--bottomup[shows aurs packages first and then repositorys]'
|
|
||||||
'--cachedir[Alternate package cache location]:cache_location:_files -/'
|
'--cachedir[Alternate package cache location]:cache_location:_files -/'
|
||||||
'--config[An alternate configuration file]:config file:_files'
|
'--config[An alternate configuration file]:config file:_files'
|
||||||
|
'--confirm[Always ask for confirmation]'
|
||||||
|
'--debug[Display debug messages]'
|
||||||
|
'--gpgdir[Set an alternate directory for GnuPG (instead of /etc/pacman.d/gnupg)]: :_files -/'
|
||||||
|
'--hookdir[Set an alternate hook location]: :_files -/'
|
||||||
'--logfile[An alternate log file]:config file:_files'
|
'--logfile[An alternate log file]:config file:_files'
|
||||||
'--noconfirm[Do not ask for confirmation]'
|
'--noconfirm[Do not ask for confirmation]'
|
||||||
'--noprogressbar[Do not show a progress bar when downloading files]'
|
'--noprogressbar[Do not show a progress bar when downloading files]'
|
||||||
'--noscriptlet[Do not execute the install scriptlet if one exists]'
|
'--noscriptlet[Do not execute the install scriptlet if one exists]'
|
||||||
'--print[Only print the targets instead of performing the operation]'
|
'--bottomup[Show AUR packages first]'
|
||||||
|
'--topdown[Show repository packages first]'
|
||||||
)
|
)
|
||||||
|
|
||||||
# options for passing to _arguments: options for --upgrade commands
|
# options for passing to _arguments: options for --upgrade commands
|
||||||
_pacman_opts_pkgfile=(
|
_pacman_opts_pkgfile=(
|
||||||
'*-d[Skip dependency checks]'
|
'*-d[Skip dependency checks]'
|
||||||
'*--nodeps[Skip dependency checks]'
|
'*--nodeps[Skip dependency checks]'
|
||||||
|
'*--assume-installed[Add virtual package to satisfy dependencies]'
|
||||||
'--dbonly[Only remove database entry, do not remove files]'
|
'--dbonly[Only remove database entry, do not remove files]'
|
||||||
'--force[Overwrite conflicting files]'
|
'--force[Overwrite conflicting files]'
|
||||||
'--needed[Do not reinstall up to date packages]'
|
'--needed[Do not reinstall up to date packages]'
|
||||||
|
'--asdeps[mark packages as non-explicitly installed]'
|
||||||
|
'--asexplicit[mark packages as explicitly installed]'
|
||||||
|
{-p,--print}'[Only print the targets instead of performing the operation]'
|
||||||
|
'*--ignore[Ignore a package upgrade]:package: _pacman_completions_all_packages'
|
||||||
|
'*--ignoregroup[Ignore a group upgrade]:package group:_pacman_completions_all_groups'
|
||||||
|
'--print-format[Specify how the targets should be printed]'
|
||||||
'*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
|
'*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,6 +75,7 @@ _pacman_opts_query_modifiers=(
|
||||||
{-l,--list}'[List package contents]'
|
{-l,--list}'[List package contents]'
|
||||||
{-m,--foreign}'[List installed packages not found in sync db(s)]'
|
{-m,--foreign}'[List installed packages not found in sync db(s)]'
|
||||||
{-n,--native}'[List installed packages found in sync db(s)]'
|
{-n,--native}'[List installed packages found in sync db(s)]'
|
||||||
|
{-q,--quiet}'[Show less information for query and search]'
|
||||||
{-t,--unrequired}'[List packages not required by any package]'
|
{-t,--unrequired}'[List packages not required by any package]'
|
||||||
{-u,--upgrades}'[List packages that can be upgraded]'
|
{-u,--upgrades}'[List packages that can be upgraded]'
|
||||||
)
|
)
|
||||||
|
@ -70,10 +83,14 @@ _pacman_opts_query_modifiers=(
|
||||||
# options for passing to _arguments: options for --remove command
|
# options for passing to _arguments: options for --remove command
|
||||||
_pacman_opts_remove=(
|
_pacman_opts_remove=(
|
||||||
{-c,--cascade}'[Remove all dependent packages]'
|
{-c,--cascade}'[Remove all dependent packages]'
|
||||||
{*-d,*--nodeps}'[Skip dependency checks]'
|
{-d,--nodeps}'[Skip dependency checks]'
|
||||||
|
'*--assume-installed[Add virtual package to satisfy dependencies]'
|
||||||
{-n,--nosave}'[Remove protected configuration files]'
|
{-n,--nosave}'[Remove protected configuration files]'
|
||||||
|
{-p,--print}'[Only print the targets instead of performing the operation]'
|
||||||
{\*-s,\*--recursive}'[Remove dependencies not required by other packages]'
|
{\*-s,\*--recursive}'[Remove dependencies not required by other packages]'
|
||||||
|
{-u,--unneeded}'[Remove unneeded packages]'
|
||||||
'--dbonly[Only remove database entry, do not remove files]'
|
'--dbonly[Only remove database entry, do not remove files]'
|
||||||
|
'--print-format[Specify how the targets should be printed]'
|
||||||
'*:installed package:_pacman_completions_installed_packages'
|
'*:installed package:_pacman_completions_installed_packages'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,6 +100,16 @@ _pacman_opts_database=(
|
||||||
'*:installed package:_pacman_completions_installed_packages'
|
'*:installed package:_pacman_completions_installed_packages'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_pacman_opts_files=(
|
||||||
|
{-l,--list}'[List the files owned by the queried package]:package:_pacman_completions_all_packages'
|
||||||
|
{-o,--owns}'[Query the package that owns]:files:_files'
|
||||||
|
{-s,--search}'[Search package file names for matching strings]:files:_files'
|
||||||
|
{-x,--regex}'[Enable searching using regluar expressions]:regex:'
|
||||||
|
{-y,--refresh}'[Download fresh files databases from the server]'
|
||||||
|
'--machinereadable[Produce machine-readable output]'
|
||||||
|
{-q,--quiet}'[Show less information for query and search]'
|
||||||
|
)
|
||||||
|
|
||||||
# options for passing to _arguments: options for --sync command
|
# options for passing to _arguments: options for --sync command
|
||||||
_pacman_opts_sync_actions=(
|
_pacman_opts_sync_actions=(
|
||||||
'(-S --sync)'{-S,--sync}
|
'(-S --sync)'{-S,--sync}
|
||||||
|
@ -97,9 +124,11 @@ _pacman_opts_sync_actions=(
|
||||||
# options for passing to _arguments: options for --sync command
|
# options for passing to _arguments: options for --sync command
|
||||||
_pacman_opts_sync_modifiers=(
|
_pacman_opts_sync_modifiers=(
|
||||||
{\*-d,\*--nodeps}'[Skip dependency checks]'
|
{\*-d,\*--nodeps}'[Skip dependency checks]'
|
||||||
|
'*--assume-installed[Add virtual package to satisfy dependencies]'
|
||||||
{\*-i,\*--info}'[View package information]'
|
{\*-i,\*--info}'[View package information]'
|
||||||
{-l,--list}'[List all packages in a repository]'
|
{-l,--list}'[List all packages in a repository]'
|
||||||
{-p,--print}'[Print download URIs for each package to be installed]'
|
{-p,--print}'[Print download URIs for each package to be installed]'
|
||||||
|
{-q,--quiet}'[Show less information for query and search]'
|
||||||
{\*-u,\*--sysupgrade}'[Upgrade all out-of-date packages]'
|
{\*-u,\*--sysupgrade}'[Upgrade all out-of-date packages]'
|
||||||
{-w,--downloadonly}'[Download packages only]'
|
{-w,--downloadonly}'[Download packages only]'
|
||||||
{\*-y,\*--refresh}'[Download fresh package databases]'
|
{\*-y,\*--refresh}'[Download fresh package databases]'
|
||||||
|
@ -108,6 +137,7 @@ _pacman_opts_sync_modifiers=(
|
||||||
'--asdeps[Install packages as non-explicitly installed]'
|
'--asdeps[Install packages as non-explicitly installed]'
|
||||||
'--asexplicit[Install packages as explicitly installed]'
|
'--asexplicit[Install packages as explicitly installed]'
|
||||||
'--force[Overwrite conflicting files]'
|
'--force[Overwrite conflicting files]'
|
||||||
|
'--print-format[Specify how the targets should be printed]'
|
||||||
)
|
)
|
||||||
|
|
||||||
# handles --help subcommand
|
# handles --help subcommand
|
||||||
|
@ -178,6 +208,14 @@ _pacman_action_database() {
|
||||||
"$_pacman_opts_database[@]"
|
"$_pacman_opts_database[@]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# handles --files subcommand
|
||||||
|
_pacman_action_files() {
|
||||||
|
_arguments -s : \
|
||||||
|
'(--files -F)'{-F,--files} \
|
||||||
|
"$_pacman_opts_common[@]" \
|
||||||
|
"$_pacman_opts_files[@]"
|
||||||
|
}
|
||||||
|
|
||||||
_pacman_action_deptest () {
|
_pacman_action_deptest () {
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
'(--deptest)-T' \
|
'(--deptest)-T' \
|
||||||
|
@ -248,23 +286,36 @@ _pacman_completions_all_groups() {
|
||||||
_pacman_get_command
|
_pacman_get_command
|
||||||
groups=( $(_call_program groups $cmd[@] -Sg) )
|
groups=( $(_call_program groups $cmd[@] -Sg) )
|
||||||
typeset -U groups
|
typeset -U groups
|
||||||
compadd "$@" -a groups
|
|
||||||
|
if [[ ${words[CURRENT-1]} == '--ignoregroup' ]]; then
|
||||||
|
_sequence compadd -S ',' "$@" -a groups
|
||||||
|
else
|
||||||
|
compadd "$@" -a groups
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# provides completions for packages available from repositories
|
# provides completions for packages available from repositories
|
||||||
# these can be specified as either 'package' or 'repository/package'
|
# these can be specified as either 'package' or 'repository/package'
|
||||||
_pacman_completions_all_packages() {
|
_pacman_completions_all_packages() {
|
||||||
local -a cmd packages repositories packages_long
|
local -a seq sep cmd packages repositories packages_long
|
||||||
_pacman_get_command
|
_pacman_get_command
|
||||||
|
|
||||||
|
if [[ ${words[CURRENT-1]} == '--ignore' ]]; then
|
||||||
|
seq='_sequence'
|
||||||
|
sep=(-S ',')
|
||||||
|
else
|
||||||
|
seq=
|
||||||
|
sep=()
|
||||||
|
fi
|
||||||
|
|
||||||
if compset -P1 '*/*'; then
|
if compset -P1 '*/*'; then
|
||||||
packages=( $(_call_program packages $cmd[@] -Sql ${words[CURRENT]%/*}) )
|
packages=( $(_call_program packages $cmd[@] -Sql ${words[CURRENT]%/*}) )
|
||||||
typeset -U packages
|
typeset -U packages
|
||||||
_wanted repo_packages expl "repository/package" compadd ${(@)packages}
|
${seq} _wanted repo_packages expl "repository/package" compadd ${sep[@]} ${(@)packages}
|
||||||
else
|
else
|
||||||
packages=( $(_call_program packages $cmd[@] -Sql) )
|
packages=( $(_call_program packages $cmd[@] -Sql) )
|
||||||
typeset -U packages
|
typeset -U packages
|
||||||
_wanted packages expl "packages" compadd - "${(@)packages}"
|
${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}"
|
||||||
|
|
||||||
repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
|
repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
|
||||||
typeset -U repositories
|
typeset -U repositories
|
||||||
|
@ -284,8 +335,8 @@ _pacman_completions_installed_groups() {
|
||||||
# provides completions for installed packages
|
# provides completions for installed packages
|
||||||
_pacman_completions_installed_packages() {
|
_pacman_completions_installed_packages() {
|
||||||
local -a cmd packages packages_long
|
local -a cmd packages packages_long
|
||||||
packages_long=(@localstatedir@/lib/pacman/local/*(/))
|
packages_long=(/var/lib/pacman/local/*(/))
|
||||||
packages=( ${${packages_long#@localstatedir@/lib/pacman/local/}%-*-*} )
|
packages=( ${${packages_long#/var/lib/pacman/local/}%-*-*} )
|
||||||
compadd "$@" -a packages
|
compadd "$@" -a packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,6 +391,9 @@ _pacman_zsh_comp() {
|
||||||
D*)
|
D*)
|
||||||
_pacman_action_database
|
_pacman_action_database
|
||||||
;;
|
;;
|
||||||
|
F*)
|
||||||
|
_pacman_action_files
|
||||||
|
;;
|
||||||
Q*g*) # ipkg groups
|
Q*g*) # ipkg groups
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
|
@ -430,6 +484,9 @@ _pacman_zsh_comp() {
|
||||||
*--database*)
|
*--database*)
|
||||||
_pacman_action_database
|
_pacman_action_database
|
||||||
;;
|
;;
|
||||||
|
*--files*)
|
||||||
|
_pacman_action_files
|
||||||
|
;;
|
||||||
*--version*)
|
*--version*)
|
||||||
_pacman_action_version
|
_pacman_action_version
|
||||||
;;
|
;;
|
||||||
|
@ -443,7 +500,6 @@ _pacman_zsh_comp() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_pacman_comp() {
|
_pacman_comp() {
|
||||||
case "$service" in
|
case "$service" in
|
||||||
yay)
|
yay)
|
||||||
|
|
Loading…
Reference in a new issue