Put pkgin dir in standard plugins dir in plugins_pkgin branch.

This commit is contained in:
Jeff LANCE 2015-12-28 16:43:59 +01:00
parent 5e7a5289cc
commit cee93e42f1
3 changed files with 134 additions and 0 deletions

11
plugins/pkgin/README.md Normal file
View File

@ -0,0 +1,11 @@
# pkgsrc autocomplete plugin
* Adds autocomplete options for pkgin commands.
## Requirements
Needs pkgsrc binary package management from Joyent : https://pkgsrc.joyent.com.
## Links
pkgsrc: http://pkgscr.net

112
plugins/pkgin/_pkgin Normal file
View File

@ -0,0 +1,112 @@
#compdef pkgin
#autoload
# pkgsrc autocomplete plugin.
# Requires pkgin: pkgsrc binary package management from Joyent.
# Author: Jeff LANCE
_pkgin_list_avail() {
pkg_available=(`pkgin avail`)
}
_pkgin_list_installed() {
pkg_installed=(`pkgin list`)
}
_pkgin_list_categories() {
pkg_categories=(`pkgin show-all-categories`)
}
_pkgin_list_kept() {
pkg_kept=(`pkgin show-keep`)
}
_pkgin_list_nokept() {
pkg_nokept=(`pkgin show-no-keep`)
}
local -a _commands
_commands=(
"list":"List installed packages"
"avail":"List available packages"
"install":"Perform packages installation or upgrade"
"update":"Create and populate the initial database"
"remove":"Remove packages and depending packages"
"upgrade":"Upgrade main packages to their newer versions"
"full-upgrade":"Upgrade all packages to their newer versions"
"show-deps":"Display direct dependencies"
"show-full-deps":"Display dependencies recursively"
"show-rev-deps":"Display reverse dependencies recursively"
"show-category":"Show packages belonging to category"
"show-pkg-category":"Show package's category"
"show-all-categories":"Show all categories"
"keep":"Mark package as \"non auto-removable\""
"unkeep":"Mark package as \"auto-removable\""
"show-keep":"Display \"non auto-removable\" packages"
"show-no-keep":"Display \"auto-removable\" packages"
"search":"Search for a package"
"clean":"Clean packages cache"
"autoremove":"Autoremove orphan dependencies"
"export":"Export \"non auto-removable\" packages to stdout"
"import":"Import \"non auto-removable\" package list from file"
"provides":"Show what files a package provides"
"requires":"Show what files a package requires"
"pkg-content":"Show remote package's content"
"pkg-descr":"Show remote package's long-description"
"pkg-build-defs":"Show remote package's build definitions"
"stats":"Packages statistics"
)
local expl
local -a pkg_available pkg_installed pkg_categories pkg_kept pkg_nokept
_arguments -s -S \
'-c[Enable chrooting pkgin in the given repository]::chroot_path:_files' \
'-d[Download only]' \
'-f[Force database update]' \
'-F[Force package reinstall]' \
'-h[Displays help for the command]' \
'-l[Only include the packages with the specified STATUS FLAGS (ls)]::n' \
'-n[Assumes "no" as default answer and print results of actions to be taken line per line]' \
'-p[Displays results in a parsable format]' \
'-P[Displays packages versions instead of globs (sd, sfd, srd)]' \
'-t[Logs package browsing (dependencies and impact) to a given log file]::log_file:_files' \
'-v[Displays pkgin version]' \
'-V[Be verbose when (un)installing]' \
'-y[Assumes "yes" as default answer, except for autoremove]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "pkgin command" _commands
return
fi
case "$words[1]" in
install|in|show-deps|sd|show-full-deps|sfd|show-rev-deps|srd \
|show-pkg-category|spc|provides|prov|requires|req \
|pkg-descr|pd|pkg-content|pc|pkg-build-defs|pbd)
_pkgin_list_avail
_wanted pkg_available expl 'all packages' compadd -a pkg_available
;;
list|ls|remove|rm)
_pkgin_list_installed
_wanted pkg_installed expl 'installed packages' compadd -a pkg_installed
;;
show-all-categories|sac|show-category|sc)
_pkgin_list_categories
_wanted pkg_categories expl "package's categories" compadd -a pkg_categories
;;
unkeep|uk)
_pkgin_list_kept
_wanted pkg_kept expl "packages marked as \"non-autoremovable\"" compadd -a pkg_kept
;;
keep|ke)
_pkgin_list_nokept
_wanted pkg_nokept expl "packages marked as \"autoremovable\"" compadd -a pkg_nokept
;;
esac

View File

@ -0,0 +1,11 @@
# pkgin aliases
alias pkgls="pkgin ls" # show installed packages
alias pkgav="pkgin av" # show available packages
alias pkgse="pkgin se $1" # search packages
alias pkgins="sudo pkgin in $1" # install package
alias pkgrm="sudo pkgin rm $1" # remove packages and depending packages
alias pkgup="sudo pkgin -y up" # create and populate the initial database
alias pkgug="sudo pkgin -y ug" # upgrade main packages
alias pkgfug="sudo pkgin -y fug" # upgrade all packages
alias pkgar="sudo pkgin -y ar" # autoremove orphan dependencies
alias pkgcl="sudo pkgin cl" # clean packages cache