#compdef pkg_add pkg_delete pkg_info (( $+functions[_bsd_pkg_pkgfiles] )) || _bsd_pkg_pkgfiles() { local ret=1 paths portsdir pkgsdir case $OSTYPE in netbsd*) portsdir=/usr/pkgsrc ;; *) portsdir=${PORTSDIR:-/usr/ports} ;; esac pkgsdir=${PACKAGES:-$portsdir/packages}/All #lx# Remote package name completion for {Free,Open}BSD #lx# #lx# Updated Wed Jan 29 13:14:06 PST 2003 to fix a regex bug. #lx# This goes and gets a list of packages from $PACKAGESITE and #lx# completes against it. For this to work, you need to specify the -r #lx# flag with pkg_add(OpenBSD doesn't have this flag, so you'll need to #lx# pkgadd $PACKAGESITE packagena and then erase the space. This #lx# file goes in ~/.zfunc, which needs to be first in your $fpath. #lx# if [ "$PACKAGESITE" != "" ] && [ "$PACKAGES" = "" ]; then zmodload zsh/zftp autoload -U zfinit zfinit zfanon `echo $PACKAGESITE|sed -e "s:^ftp\://::" -e "s:/.*::"` >/dev/null 2>&1 zfcd `echo $PACKAGESITE|sed -e "s:^ftp\://[a-zA-Z0-9.]*/:/:"` >/dev/null 2>&1 PACKAGES=`zfls` PACKAGES=`echo $PACKAGES|tr -s "\n" " "` zfclose fi paths=( "${(@)${(@s.:.)PKG_PATH}:#}" ) _files "$@" -g '*.t[bg]z' && ret=0 (( $#path )) && _files "$@" -W paths -g '*.t[bg]z' && ret=0 compadd "$@" - $pkgsdir/*.t[bg]z && ret=0 compadd "$@" - `echo $PACKAGES` && ret=0 #lx# #lx# below here is unchanged. #lx# return ret } (( $+functions[_bsd_pkg_pkgs] )) || _bsd_pkg_pkgs() { compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(/:t) } (( $+functions[_bsd_pkg_pkgs_and_files] )) || _bsd_pkg_pkgs_and_files() { local ret=1 if (( $words[(I)-*F*] )); then _files "$@" && ret=0 else _bsd_pkg_pkgs "$@" && ret=0 fi return ret } _bsd_pkg() { local flags case "$service" in pkg_add) flags=( '-f[force installation]' '-I[don'\''t execute installation scripts]' '-M[run in master mode]' '-n[don'\''t really install packages]' '-p[specify prefix]:prefix directory:_files -/' '-R[don'\''t record]' '-S[run in slave mode]' '-t[specify mktemp template]:mktemp template:_files -/' '-v[be verbose]' ) case "$OSTYPE" in freebsd*) flags=( $flags[@] '-r[fetch from remote site]' ) ;; netbsd*) flags=( $flags[@] '-u[update]' '-V[show version and exit]' ) ;; esac _arguments -s \ $flags[@] \ '*:package to install:_bsd_pkg_pkgfiles' ;; pkg_delete) flags=( '-D[don'\''t execute deinstallation scripts]' '-d[remove empty directories]' '-f[force deinstallation]' '-n[don'\''t really deinstall packages]' '-p[specify prefix]:prefix directory:_files -/' '-v[be verbose]' ) case "$OSTYPE" in freebsd*) flags=( $flags[@] '(:)-a[delete all installed packages]' '-G[do not expand glob patterns]' '-i[be interactive]' '-r[delete recursively]' '-x[use regular expression]' ) ;; netbsd*) flags=( $flags[@] '(:)-a[delete all installed packages]' '-F[specify each package by an installed file]' '-i[be interactive]' '-O[only delete the package'\''s entries]' '-R[delete upward recursively]' '-r[delete recursively]' '-V[show version and exit]' ) ;; esac _arguments -s \ $flags[@] \ '(-a)*:package name:_bsd_pkg_pkgs_and_files' ;; pkg_info) flags=( '(:)-a[show all installed packages]' '-c[show comment fields]' '-D[show install-message files]' '-d[show long descriptions]' '-e[test if package is installed]:package name:_bsd_pkg_pkgs' '-f[show packing list instructions]' '-I[show index lines]' '-i[show install scripts]' '-k[show deinstall scripts]' '-L[show full pathnames of files]' '-l[specify prefix string]:prefix string:' '-m[show mtree files]' '-p[show installation prefixes]' '-q[be quiet]' '-R[show list list of installed requiring packages]' '-r[show requirements scripts]' '-v[be verbose]' ) case "$OSTYPE" in freebsd*) flags=( $flags[@] '-G[do not expand glob patterns]' '-g[show files that'\''s modified]' '-o[show origin]' '-s[show total size occupied by each package]' '-t[specify mktemp template]:mktemp template:_files -/' '*-W[show which package the file belongs to]:file:_files' '-x[use regular expression]' ) ;; netbsd*) flags=( $flags[@] '-B[show build information]' '-b[show RCS Id strings]' '-F[specify each package by an installed file]' '-S[show total size occupied by each package and its dependents]' '-s[show total size occupied by each package]' '-V[show version and exit]' ) ;; esac _arguments -s \ $flags[@] \ '(-a)*:package name:_bsd_pkg_pkgs_and_files' ;; esac } _bsd_pkg "$@"