mirror of
https://github.com/Jguer/yay
synced 2024-10-31 04:12:51 +00:00
Should resolve #2. Added new options for zsh completion and made the file smaller.
This commit is contained in:
parent
6d06f1687d
commit
93f008919c
2 changed files with 9 additions and 213 deletions
|
@ -27,9 +27,9 @@ func usage() {
|
||||||
yay -G [package(s)] get pkgbuild from ABS or AUR
|
yay -G [package(s)] get pkgbuild from ABS or AUR
|
||||||
|
|
||||||
New options:
|
New options:
|
||||||
--topdown shows repository's packages first and then aur's
|
--topdown shows repository's packages first and then aur's
|
||||||
--bottomup shows aur's packages first and then repository's
|
--bottomup shows aur's packages first and then repository's
|
||||||
--noconfirm skip user input on package install
|
--noconfirm skip user input on package install
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
216
zsh-completion
216
zsh-completion
|
@ -1,4 +1,4 @@
|
||||||
#compdef pacman pacman.static=pacman pacman-key makepkg
|
#compdef yay yay.static=yay
|
||||||
|
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
setopt extendedglob
|
setopt extendedglob
|
||||||
|
@ -6,6 +6,7 @@ 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]'
|
||||||
{-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]'
|
||||||
|
@ -22,6 +23,8 @@ _pacman_opts_common=(
|
||||||
{-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'
|
||||||
'--logfile[An alternate log file]:config file:_files'
|
'--logfile[An alternate log file]:config file:_files'
|
||||||
|
@ -263,7 +266,7 @@ _pacman_completions_all_packages() {
|
||||||
typeset -U packages
|
typeset -U packages
|
||||||
_wanted packages expl "packages" compadd - "${(@)packages}"
|
_wanted packages expl "packages" compadd - "${(@)packages}"
|
||||||
|
|
||||||
repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
|
repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
|
||||||
typeset -U repositories
|
typeset -U repositories
|
||||||
_wanted repo_packages expl "repository/package" compadd -S "/" $repositories
|
_wanted repo_packages expl "repository/package" compadd -S "/" $repositories
|
||||||
fi
|
fi
|
||||||
|
@ -295,7 +298,7 @@ _pacman_all_packages() {
|
||||||
# provides completions for repository names
|
# provides completions for repository names
|
||||||
_pacman_completions_repositories() {
|
_pacman_completions_repositories() {
|
||||||
local -a cmd repositories
|
local -a cmd repositories
|
||||||
repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
|
repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
|
||||||
# Uniq the array
|
# Uniq the array
|
||||||
typeset -U repositories
|
typeset -U repositories
|
||||||
compadd "$@" -a repositories
|
compadd "$@" -a repositories
|
||||||
|
@ -441,215 +444,8 @@ _pacman_zsh_comp() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_key_shortopts=(
|
|
||||||
'-h[show help]'
|
|
||||||
'-a[Add the specified keys (empty for stdin)]: :_files'
|
|
||||||
'-d[Remove the Specified keyids]:*: :_keys'
|
|
||||||
'-e[Export the specified or all keyids]:*: :_keys'
|
|
||||||
'-f[List fingreprint for specidied or all keyids]:*: :_keys'
|
|
||||||
'-l[List the specified or all keys]:*: :_keys'
|
|
||||||
'-r[Fetch the specified keyids]:*: :_keys'
|
|
||||||
'-u[Update the trustdb of pacman]'
|
|
||||||
'-v[Verify the file specified by the signature]: :_files -g "*.sig"'
|
|
||||||
'-V[Show program version]'
|
|
||||||
)
|
|
||||||
|
|
||||||
_key_longopts=(
|
|
||||||
'--help[show help]'
|
|
||||||
'--add[Add the specified keys (empty for stdin)]: :_files'
|
|
||||||
'--delete[Remove the Specified keyids]:*: :_keys'
|
|
||||||
'--export[Export the specified or all keyids]:*: :_keys'
|
|
||||||
'--finger[List fingreprint for specidied or all keyids]:*: :_keys'
|
|
||||||
'--list-keys[List the specified or all keys]:*: :_keys'
|
|
||||||
'--recv-keys[Fetch the specified keyids]:*: :_keys'
|
|
||||||
'--updatedb[Update the trustdb of pacman]'
|
|
||||||
'--verify[Verify the file specified by the signature]: :_files -g "*.sig"'
|
|
||||||
'--version[Show program version]'
|
|
||||||
'--edit-key[Present a menu for key management task on keyids]:*: :_keys'
|
|
||||||
'--import[Imports pubring.gpg from dir(s)]: :_files -g "*.gpg"'
|
|
||||||
'--import-tb[Imports ownertrust values from trustdb.gpg in dir(s)]: :_files -g "*.gpg"'
|
|
||||||
'--init[Ensure the keyring is properly initialized]'
|
|
||||||
'--list-sigs[List keys and their signatures]:*: :_keys'
|
|
||||||
'--lsign-key[Locally sign the specified keyid]:*: :_keys'
|
|
||||||
'--populate[Reload the default keys from the (given) keyrings in '/usr/share/pacman/keyrings']: :_path_files -W /usr/share/pacman/keyrings'
|
|
||||||
'--refresh-keys[Update specified or all keys from a keyserver]:*: :_keys'
|
|
||||||
)
|
|
||||||
|
|
||||||
_pacman_key_options=(
|
|
||||||
'--config[Use an alternate config file (instead of @sysconfdir@/pacman.conf)]: :_files'
|
|
||||||
'--gpgdir[Set an alternate directory for GnuPG (instead of @sysconfdir@/pacman.d/gnupg)]: :_files -/'
|
|
||||||
'--keyserver[Specify a keyserver to use if necessary]'
|
|
||||||
)
|
|
||||||
|
|
||||||
_pacman_key() {
|
|
||||||
case $words[CURRENT] in
|
|
||||||
--*)
|
|
||||||
_arguments -s : \
|
|
||||||
"$_pacman_key_options[@]" \
|
|
||||||
"$_key_longopts[@]"
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
_arguments -s : \
|
|
||||||
"$_pacman_key_options[@]" \
|
|
||||||
"$_key_shortopts[@]" \
|
|
||||||
"$_key_longopts[@]"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
i=$#;
|
|
||||||
while [[ $words[$i] != -* ]] && [[ $words[$i] != "pacman-key" ]];do
|
|
||||||
i=$(($i-1))
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
--*)
|
|
||||||
_arguments -s : \
|
|
||||||
"$_pacman_key_options[@]" \
|
|
||||||
"$_key_longopts[@]"
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
_arguments -s : \
|
|
||||||
"$_pacman_key_options[@]" \
|
|
||||||
"$_key_shortopts[@]" \
|
|
||||||
"$_key_longopts[@]"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
_keys() {
|
|
||||||
local keylist keys
|
|
||||||
keylist=$(pacman-key --list-keys 2>/dev/null | awk '
|
|
||||||
$1 == "pub" {
|
|
||||||
# key id
|
|
||||||
split($2, a, "/"); print a[2]
|
|
||||||
}
|
|
||||||
$1 == "uid" {
|
|
||||||
# email
|
|
||||||
if (match($NF, /<[^>]+>/))
|
|
||||||
print substr($NF, RSTART + 1, RLENGTH - 2)
|
|
||||||
#this adds support for names as well if that is ever added
|
|
||||||
}
|
|
||||||
$1 == "uid" {
|
|
||||||
for (i=2;i<NF;i++) {printf "%s%s",sep, $i;sep=" "}; printf "\n"
|
|
||||||
}' |sed -e 's/(.*)//g' -e 's/^\ //g' -e 's/\ *$//g' |uniq
|
|
||||||
)
|
|
||||||
keys=(${(s:/:)${keylist//$'\n'/\/}})
|
|
||||||
_describe -t modules 'keys in keyring' keys && return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
_makepkg_shortopts=(
|
|
||||||
'-s[Install missing dependencies with pacman]'
|
|
||||||
'-i[Install package after successful build]'
|
|
||||||
'-A[Ignore incomplete arch field in PKGBUILD]'
|
|
||||||
'-c[Clean up work files after build]'
|
|
||||||
'-d[Skip all dependency checks]'
|
|
||||||
'-e[Do not extract source files (use existing src/ dir)]'
|
|
||||||
'-f[Overwrite existing package]'
|
|
||||||
'-g[Generate integrity checks for source files]'
|
|
||||||
'-h[Show help message and exit]'
|
|
||||||
'-L[Log package build process]'
|
|
||||||
'-m[Disable colorized output messages]'
|
|
||||||
'-o[Download and extract files only]'
|
|
||||||
'-p[Use an alternate build script (instead of 'PKGBUILD')]: :_files'
|
|
||||||
'-r[Remove installed dependencies after a successful build]'
|
|
||||||
'-R[Repackage contents of the package without rebuilding]'
|
|
||||||
'-S[Generate a source-only tarball without downloading sources]'
|
|
||||||
)
|
|
||||||
|
|
||||||
_makepkg_action_none(){
|
|
||||||
_arguments \
|
|
||||||
"$_makepkg_shortopts[@]" \
|
|
||||||
"$_makepkg_longopts[@]"
|
|
||||||
}
|
|
||||||
_makepkg_longopts=(
|
|
||||||
'--ignorearch[Ignore incomplete arch field in PKGBUILD]'
|
|
||||||
'--clean[Clean up work files after build]'
|
|
||||||
'--nodeps[Skip all dependency checks]'
|
|
||||||
'--noextract[Do not extract source files (use existing src/ dir)]'
|
|
||||||
'--force[Overwrite existing package]'
|
|
||||||
'--geninteg[Generate integrity checks for source files]'
|
|
||||||
'--help[Show help message and exit]'
|
|
||||||
'--install[Install package after successful build]'
|
|
||||||
'--log[Log package build process]'
|
|
||||||
'--nocolor[Disable colorized output messages]'
|
|
||||||
'--nobuild[Download and extract files only]'
|
|
||||||
'--rmdeps[Remove installed dependencies after a successful build]'
|
|
||||||
'--repackage[Repackage contents of the package without rebuilding]'
|
|
||||||
'--syncdeps[Install missing dependencies with pacman]'
|
|
||||||
'--source[Generate a source-only tarball without downloading sources]'
|
|
||||||
'--allsource[Generate a source-only tarball including downloaded source]'
|
|
||||||
'--asroot[Allow makepkg to run as root user]'
|
|
||||||
'--check[Run check() function in the PKGBUILD]'
|
|
||||||
'--config[Use an alternate config file instead of '@sysconfdir@/makepkg.conf']: :_files'
|
|
||||||
'--holdver[Prevent automatic version bumping for development PKGBUILDs]'
|
|
||||||
'--key[Specify key to use for gpg signing instead of the default]: :_keys'
|
|
||||||
'--nocheck[Do not run the check() function in the PKGBUILD]'
|
|
||||||
'--noprepare[Do not run the prepare() function in the PKGBUILD]'
|
|
||||||
'--nosign[Do not create a signature for the package]'
|
|
||||||
'--pkg[Only build listed packages from a split package]'
|
|
||||||
'--sign[Sign the resulting package with gpg]'
|
|
||||||
'--skipchecksums[Do not verify checksums of the source files]'
|
|
||||||
'--skipinteg[do not perform any verification checks on source files]'
|
|
||||||
'--skippgpcheck[Do not verify source files with PGP signatures]'
|
|
||||||
'--noconfirm[do not ask for confirmation when resolving dependencies]'
|
|
||||||
'--asdeps[Install packages as non-explicitly installed]'
|
|
||||||
'--noprogressbar[Do not show a progress bar when downloading files]'
|
|
||||||
'--needed[Do not reinstall up-to-date packages]'
|
|
||||||
'--verifysource[Only download sources and verify checksums]'
|
|
||||||
)
|
|
||||||
_makepkg(){
|
|
||||||
case $words[CURRENT] in
|
|
||||||
-*)
|
|
||||||
_arguments -s -w : \
|
|
||||||
"$_makepkg_shortopts[@]" \
|
|
||||||
"$_makepkg_longopts[@]"
|
|
||||||
;;
|
|
||||||
--* )
|
|
||||||
_arguments -s \
|
|
||||||
"$_makepkg_longopts[@]"
|
|
||||||
;;
|
|
||||||
- )
|
|
||||||
_makepkg_action_none
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
i=$#
|
|
||||||
while [[ $words[i] != -* ]] && [[ $words[$i] != "makepkg" ]];do
|
|
||||||
i=$((i-1));
|
|
||||||
done
|
|
||||||
case $words[$i] in
|
|
||||||
-*)
|
|
||||||
_arguments -s -w : \
|
|
||||||
"$_makepkg_shortopts[@]" \
|
|
||||||
"$_makepkg_longopts[@]"
|
|
||||||
;;
|
|
||||||
--* )
|
|
||||||
_arguments -s \
|
|
||||||
"$_makepkg_longopts[@]"
|
|
||||||
;;
|
|
||||||
- )
|
|
||||||
_makepkg_action_none
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
_pacman_comp() {
|
_pacman_comp() {
|
||||||
case "$service" in
|
case "$service" in
|
||||||
makepkg)
|
|
||||||
_makepkg "$@"
|
|
||||||
;;
|
|
||||||
pacman-key)
|
|
||||||
_pacman_key "$@"
|
|
||||||
;;
|
|
||||||
pacman)
|
|
||||||
_pacman_zsh_comp "$@"
|
|
||||||
;;
|
|
||||||
yay)
|
yay)
|
||||||
_pacman_zsh_comp "$@"
|
_pacman_zsh_comp "$@"
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue