#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