diff --git a/custom/plugins/pkgin/README.md b/custom/plugins/pkgin/README.md new file mode 100644 index 00000000..2f61cabe --- /dev/null +++ b/custom/plugins/pkgin/README.md @@ -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 diff --git a/custom/plugins/pkgin/_pkgin b/custom/plugins/pkgin/_pkgin new file mode 100644 index 00000000..3e271145 --- /dev/null +++ b/custom/plugins/pkgin/_pkgin @@ -0,0 +1,112 @@ +#compdef pkgin +#autoload + + +# pkgsrc autocomplete plugin +# Requires pkgin: pkgsrc 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 diff --git a/custom/plugins/pkgin/pkgin.plugin.zsh b/custom/plugins/pkgin/pkgin.plugin.zsh new file mode 100644 index 00000000..998d5cfa --- /dev/null +++ b/custom/plugins/pkgin/pkgin.plugin.zsh @@ -0,0 +1,11 @@ +# 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