about summary refs log tree commit diff
path: root/Completion/Unix/Type
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Type')
-rw-r--r--Completion/Unix/Type/_dir_list29
-rw-r--r--Completion/Unix/Type/_domains20
-rw-r--r--Completion/Unix/Type/_groups24
-rw-r--r--Completion/Unix/Type/_java_class24
-rw-r--r--Completion/Unix/Type/_perl_basepods32
-rw-r--r--Completion/Unix/Type/_perl_modules119
-rw-r--r--Completion/Unix/Type/_pids54
-rw-r--r--Completion/Unix/Type/_ports12
-rw-r--r--Completion/Unix/Type/_printers72
-rw-r--r--Completion/Unix/Type/_services18
-rw-r--r--Completion/Unix/Type/_tex6
-rw-r--r--Completion/Unix/Type/_texi6
-rw-r--r--Completion/Unix/Type/_time_zone9
13 files changed, 425 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_dir_list b/Completion/Unix/Type/_dir_list
new file mode 100644
index 000000000..536d424e3
--- /dev/null
+++ b/Completion/Unix/Type/_dir_list
@@ -0,0 +1,29 @@
+#compdef -value-,TERMINFO_DIRS,-default- -P -value-,*PATH,-default-
+
+# options:
+#  -s <sep> to specify the separator (default is a colon)
+#  -S       to say that the separator should be added as a suffix (instead
+#           of the default slash)
+# any description passed should apply to an individual directory and not
+# to the entire list
+
+local sep=: dosuf suf
+
+while [[ "$1" = -(s*|S) ]]; do
+  case "$1" in
+  -s)  sep="$2"; shift 2;;
+  -s*) sep="${1[3,-1]}"; shift;;
+  -S)  dosuf=yes; shift;;
+  esac
+done
+
+compset -P "*${sep}"
+compset -S "${sep}*" || suf="$sep"
+
+if [[ -n "$dosuf" ]]; then
+  suf=(-S "$suf")
+else
+  suf=()
+fi
+
+_directories "$suf[@]" -r "${sep}"' /\t\t\-' "$@"
diff --git a/Completion/Unix/Type/_domains b/Completion/Unix/Type/_domains
new file mode 100644
index 000000000..851ac7930
--- /dev/null
+++ b/Completion/Unix/Type/_domains
@@ -0,0 +1,20 @@
+#autoload
+
+local expl domains tmp
+
+if ! zstyle -a ":completion:${curcontext}:domains" domains domains; then
+  if (( ! $+_cache_domains )); then
+    _cache_domains=()
+    if [[ -f /etc/resolv.conf ]]; then
+      while read tmp; do
+        [[ "$tmp" = (domain|search)* ]] &&
+            _cache_domains=( "$_cache_domains[@]" "${=${tmp%%[ 	]#}#*[ 	]}" )
+      done < /etc/resolv.conf
+      _cache_domains=( "${(@)_cache_domains:#[ 	]#}" )
+    fi
+  fi
+  domains=( "$_cache_domains[@]" )
+fi
+
+_wanted domains expl domain \
+    compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' -a "$@" - domains
diff --git a/Completion/Unix/Type/_groups b/Completion/Unix/Type/_groups
new file mode 100644
index 000000000..923c34599
--- /dev/null
+++ b/Completion/Unix/Type/_groups
@@ -0,0 +1,24 @@
+#compdef newgrp groupdel
+
+local expl groups tmp
+
+_tags groups || return 1
+
+if ! zstyle -a ":completion:${curcontext}:" groups groups; then
+  (( $+_cache_groups )) ||
+      if [[ $OSTYPE = darwin* ]]; then
+        : ${(A)_cache_groups:=${${(M)${(f)"$(_call_program groups lookupd -q group)"}:#name*}##*: }}
+      elif (( ${+commands[getent]} )); then
+        : ${(A)_cache_groups:=${${(s: :)$(_call_program groups getent group 2>/dev/null)}%%:*}}
+      else
+        : ${(A)_cache_groups:=${${${(s: :)$(</etc/group)}%%:*}:#+}}
+	if (( ${+commands[ypcat]} )) &&
+	    tmp=$(_call_program groups ypcat group.byname 2>/dev/null); then
+          _cache_groups+=( ${${(f)tmp}%%:*} ) # If you use YP
+	fi
+      fi
+
+  groups=( "$_cache_groups[@]" )
+fi
+
+_wanted groups expl group compadd -a "$@" - groups
diff --git a/Completion/Unix/Type/_java_class b/Completion/Unix/Type/_java_class
new file mode 100644
index 000000000..d81669c00
--- /dev/null
+++ b/Completion/Unix/Type/_java_class
@@ -0,0 +1,24 @@
+#autoload
+
+# Should probably add some sort of cache.
+# Should we call _multi_parts instead of compadd?
+
+local classpath i expl
+local -a c
+local method type
+
+zparseopts -D -E -a classpath t:=type m:=method cp: classpath:
+: "$classpath[@]"
+classpath="${${classpath[2]:-${CLASSPATH:-.}}//\\:/:}"
+: "$classpath[@]"
+
+for i in "${(s.:.)classpath}"; do
+  if [ -f $i ] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
+    c+=( ${${${(M)$(_call_program jar_classes jar -tf $i)##*.class}%%.class}:gs#/#.#} )
+  elif [ -d $i ]; then
+    c+=( $i/**/*.class(.:r:s/.class//:s#$i/##:gs#/#.#) )
+  fi
+done
+
+_wanted classes expl 'java class' compadd "$@" -M 'r:|.=* r:|=*' -a - c
+
diff --git a/Completion/Unix/Type/_perl_basepods b/Completion/Unix/Type/_perl_basepods
new file mode 100644
index 000000000..80a8c8321
--- /dev/null
+++ b/Completion/Unix/Type/_perl_basepods
@@ -0,0 +1,32 @@
+#autoload
+#
+# _perl_basepods - zsh completion function
+#
+# Adam Spiers <adam@spiers.net>
+#
+# Calculate all installed Perl base pods (perlfunc, perlfaq etc.).
+# The result is cached for future use.
+#
+
+if (( ! $+_perl_basepods )); then
+  typeset -agU _perl_basepods
+
+  if (( ${+commands[basepods]} )); then
+    _perl_basepods=( ${$(basepods):t:r} )
+  else
+    local podpath
+
+    podpath=$(perl -MConfig -e 'print "$Config{installprivlib}/pod"')
+
+    if [[ ! -e $podpath/perl.pod ]]; then
+      _message "can't find perl.pod from Config.pm; giving up"
+      return 1
+    else
+      _perl_basepods=( ${podpath}/*.pod(:r:t) )
+    fi
+  fi
+fi
+
+local expl
+
+_wanted pods expl 'perl base pod' compadd -a "$@" - _perl_basepods
diff --git a/Completion/Unix/Type/_perl_modules b/Completion/Unix/Type/_perl_modules
new file mode 100644
index 000000000..ba88d8d52
--- /dev/null
+++ b/Completion/Unix/Type/_perl_modules
@@ -0,0 +1,119 @@
+#compdef pmpath pmvers pmdesc pmload pmexp pmeth pmls pmcat pman pmfunc podgrep podtoc podpath
+#
+# _perl_modules - zsh completion function
+#
+# Adam Spiers <adam@spiers.net>
+#
+# Calculate all installed Perl modules.  The result is cached
+# for future use.
+# 
+# Options:
+# 
+# -t[types]: indicate file types; currently the only one is -tP,
+# to include .pod files as well as modules.
+# 
+# Available styles:
+#
+# * try-to-use-pminst
+#
+#   Set this if you have pminst and want to use it.  The zsh code
+#   actually produces better results because pminst misses modules of
+#   the form Foo/bar/Baz.pm through its clumsy -d && /^[A-Z]/ && prune
+#   algorithm (the zsh code does almost the same, but only misses
+#   modules which don't begin with an uppercase letter).
+
+_perl_modules () {
+  # Set a sensible default caching policy.  This has to be done inside
+  # this function otherwise we wouldn't know the context for the style.
+  local update_policy sufpat=".pm" with_pod
+  zstyle -s ":completion:${curcontext}:" cache-policy update_policy
+  if [[ -z "$update_policy" ]]; then
+    zstyle ":completion:${curcontext}:" cache-policy \
+      _perl_modules_caching_policy
+  fi
+
+  if [[ $argv[-1] = -tP ]]; then
+    argv=("${(@)argv[1,-2]}")
+    sufpat="(.pm|.pod)"
+    with_pod=_with_pod
+  fi
+
+  local perl=${words[1]%doc} perl_modules
+  if whence $perl >/dev/null; then
+    perl_modules=_${${perl//[^[:alnum:]]/_}#_}_modules$with_pod
+  elif (( ${+commands[perl]} )); then
+    perl=perl
+    perl_modules=_perl_modules$with_pod
+  else
+    perl=
+    perl_modules=_unknown_perl_modules$with_pod
+  fi
+
+  if ( [[ ${(P)+perl_modules} -eq 0 ]] || _cache_invalid $perl_modules ) &&
+     ! _retrieve_cache ${perl_modules#_};
+  then
+    if zstyle -t ":completion:${curcontext}:modules" try-to-use-pminst &&
+       (( ${+commands[pminst]} ));
+    then
+      set -A $perl_modules $(pminst)
+    else
+      local inc libdir new_pms
+
+      if [[ ${+perl} -eq 1 ]]; then
+        inc=( $( $perl -e 'print "@INC"' ) )
+      else
+        # If perl isn't there, one wonders why the user's trying to
+        # complete Perl modules.  Maybe her $path is wrong?
+        _message "didn't find perl on \$PATH; guessing @INC ..."
+
+        inc=( /usr/lib/perl5{,/{site_perl/,}<5->.([0-9]##)}(N) 
+              ${(s.:.)PERL5LIB} )
+      fi
+
+      typeset -agU $perl_modules  # $perl_modules is global, no duplicates
+      set -A $perl_modules
+
+      for libdir in $inc; do
+        # Ignore cwd - could be too expensive e.g. if we're near /
+        if [[ $libdir == '.' ]]; then continue; fi
+
+        # Find all modules
+        if [[ -d $libdir && -x $libdir ]]; then
+          new_pms=( $libdir/{[A-Z]*/***/,}*${~sufpat}~*blib* )
+          new_pms=( "${(@)new_pms##$libdir/##}" )
+        fi
+
+        # Convert to Perl nomenclature
+        new_pms=( ${new_pms:r:fs#/#::#} )
+
+        set -A $perl_modules $new_pms ${(P)perl_modules}
+      done
+    fi
+
+    _store_cache ${perl_modules#_} $perl_modules
+  fi
+
+  local expl
+
+  _wanted modules expl 'Perl module' compadd "$@" -a - $perl_modules
+}
+
+_perl_modules_caching_policy () {
+  local _perllocals
+
+  # rebuild if cache is more than a week old
+  oldp=( "$1"(mw+1) )
+  (( $#oldp )) && return 0
+
+  _perllocals=( /usr/lib/perl5/**/perllocal.pod )
+
+  if (( $#_perllocals )); then
+    for pod in $_perllocals; do
+      [[ "$pod" -nt "$1" ]] && return 0
+    done
+  fi
+
+  return 1
+}
+
+_perl_modules "$@"
diff --git a/Completion/Unix/Type/_pids b/Completion/Unix/Type/_pids
new file mode 100644
index 000000000..18ed4616e
--- /dev/null
+++ b/Completion/Unix/Type/_pids
@@ -0,0 +1,54 @@
+#compdef pflags pcred pmap pldd psig pstack pfiles pwdx pstop prun pwait ptree
+
+# If given the `-m <pattern>' option, this tries to complete only pids
+# of processes whose command line match the `<pattern>'.
+
+local out pids list expl match desc listargs all nm ret=1
+
+_tags processes || return 1
+
+if [[ "$1" = -m ]]; then
+  all=()
+  match="*[[:blank:]]${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*[/[:blank:]]${2}*"
+  shift 2
+elif [[ "$PREFIX$SUFFIX" = ([%-]*|[0-9]#) ]]; then
+  all=()
+  match="(*[[:blank:]]|)${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*"
+else
+  all=(-U)
+  match="*[[:blank:]]*[[/[:blank:]]$PREFIX*$SUFFIX*"
+  nm="$compstate[nmatches]"
+fi
+
+out=( "${(@f)$(_call_program processes ps 2>/dev/null)}" )
+desc="$out[1]"
+out=( "${(@M)out[2,-1]:#${~match}}" )
+
+if [[ "$desc" = (#i)(|*[[:blank:]])pid(|[[:blank:]]*) ]]; then
+  pids=( "${(@)${(@M)out#${(l.${#desc[1,(r)(#i)[[:blank:]]pid]}..?.)~:-}[^[:blank:]]#}##*[[:blank:]]}" )
+else
+  pids=( "${(@)${(@M)out##[^0-9]#[0-9]#}##*[[:blank:]]}" )
+fi
+
+if zstyle -T ":completion:${curcontext}:processes" verbose; then
+  list=( "${(@Mr:COLUMNS-1:)out}" )
+  desc=(-ld list)
+else
+  desc=()
+fi
+
+_wanted processes expl 'process ID' \
+    compadd "$@" "$desc[@]" "$all[@]" -a - pids && ret=0
+
+if [[ -n "$all" ]]; then
+  zstyle -s ":completion:${curcontext}:processes" insert-ids out || out=menu
+
+  case "$out" in
+  menu)   compstate[insert]=menu ;;
+  single) [[ $compstate[nmatches] -ne nm+1 ]] && compstate[insert]= ;;
+  *)      [[ ${#:-$PREFIX$SUFFIX} -gt ${#compstate[unambiguous]} ]] &&
+              compstate[insert]=menu ;;
+  esac
+fi
+
+return ret
diff --git a/Completion/Unix/Type/_ports b/Completion/Unix/Type/_ports
new file mode 100644
index 000000000..8c8da531e
--- /dev/null
+++ b/Completion/Unix/Type/_ports
@@ -0,0 +1,12 @@
+#autoload
+
+local expl ports
+
+if ! zstyle -a ":completion:${curcontext}:" ports ports; then
+  (( $+_cache_ports )) ||
+      : ${(A)_cache_ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ 	]*}}
+
+  ports=( "$_cache_ports[@]" )
+fi
+
+_wanted ports expl port compadd -a "$@" - ports
diff --git a/Completion/Unix/Type/_printers b/Completion/Unix/Type/_printers
new file mode 100644
index 000000000..edbc9aaae
--- /dev/null
+++ b/Completion/Unix/Type/_printers
@@ -0,0 +1,72 @@
+#compdef -value-,PRINTER,-default- -value-,LPDEST,-default-
+
+local expl ret=1 list disp sep tmp
+
+if (( $+commands[lsallq] )); then
+  # Use AIX's command to list print queues
+  _wanted printers expl printer compadd "$@" - $(lsallq)
+  return
+fi
+
+zstyle -s ":completion:${curcontext}:printers" list-separator sep || sep=--
+
+if (( ! $+_lp_cache )); then
+  local file entry names i
+
+  file=( /etc/(printcap|printers.conf) )
+
+  _lp_cache=()
+  _lp_alias_cache=()
+
+  if (( $#file )); then
+    while read entry; do
+      if [[ "$entry" = [^[:blank:]\#\*_]*:* ]]; then
+        names=( "${(s:|:)entry%%:*}" )
+        if [[ "$entry" = *:description=* ]]; then
+          disp="${${entry##*:description=}%%:*}"
+        elif [[ $#names -gt 1 && "$names[-1]" = *\ * ]] ;then
+          disp="$names[-1]"
+        else
+          disp=''
+        fi
+        if [[ -n "$disp" ]]; then
+          _lp_cache+=( "${names[1]}:${disp}" )
+  	  _lp_alias_cache+=( "${(@)^names[2,-1]:#*\ *}:${disp}" )
+        else
+          _lp_cache+=( "${names[1]}" )
+  	  _lp_alias_cache+=( "${(@)names[2,-1]:#*\ *}" )
+        fi
+      fi
+    done < $file[1]
+  fi
+
+  if [[ $OSTYPE = solaris* ]] && (( ${+commands[ypcat]} )) &&
+      tmp=$(_call_program printers ypcat printers.conf.byname 2>/dev/null); then
+    _lp_cache+=( ${${${(S)${(f)tmp}/(#b):*((#e)|description=([^:]#):)*/:${match[2]}|}%%|*}:#_default*} ) # If you use YP
+  fi
+
+  (( $#_lp_cache )) || _lp_cache=( 'lp0:Guessed default printer' )
+  (( $#_lp_alias_cache )) || unset _lp_alias_cache
+fi
+
+if zstyle -T ":completion:${curcontext}:printers" verbose; then
+  zformat -a list " $sep " "$_lp_cache[@]"
+  disp=(-ld list)
+else
+  disp=()
+fi
+_wanted printers expl printer \
+    compadd "$@" "$disp[@]" - "${(@)_lp_cache%%:*}" && return 0
+
+(( $+_lp_alias_cache )) || return 1
+
+if zstyle -T ":completion:${curcontext}:printers" verbose; then
+  zformat -a list " $sep " "$_lp_alias_cache[@]"
+  disp=(-ld list)
+else
+  disp=()
+fi
+_wanted printers expl printer \
+    compadd "$@" "$disp[@]" - "${(@)_lp_alias_cache%%:*}" && return 0
+
+return 1
diff --git a/Completion/Unix/Type/_services b/Completion/Unix/Type/_services
new file mode 100644
index 000000000..2965e0f3e
--- /dev/null
+++ b/Completion/Unix/Type/_services
@@ -0,0 +1,18 @@
+#autoload
+
+local -a inits xinetds alls
+local expl ret=1
+
+if chkconfig --list > /dev/null 2>&1; then
+  alls=( ${(f)"$(LANGUAGE=C LANG=C LC_ALL=C chkconfig --list)"} )
+  inits=( ${${${alls[1,(r)xinetd based*]}[1,-2]}/%[[:space:]]*/} )
+  xinetds=( ${${${${alls[(r)xinetd based*,-1]}[2,-1]}/#[[:space:]]#}/%:*} )
+
+  _alternative \
+    'init:init service:compadd -a inits' \
+    'xinetd:xinetd service:compadd -a xinetds' && ret=0
+else
+  _wanted services expl service compadd "$@" - /etc/init.d/*(-*:t) && ret=0
+fi
+
+return ret
diff --git a/Completion/Unix/Type/_tex b/Completion/Unix/Type/_tex
new file mode 100644
index 000000000..fcbafbd67
--- /dev/null
+++ b/Completion/Unix/Type/_tex
@@ -0,0 +1,6 @@
+#compdef tex latex slitex pdflatex jadetex pdfjadetex
+
+local expl
+
+_description files expl 'TeX or LaTeX file'
+_files "$@" "$expl[@]" -g '*.(tex|TEX|texinfo|texi)(-.)'
diff --git a/Completion/Unix/Type/_texi b/Completion/Unix/Type/_texi
new file mode 100644
index 000000000..10ccfa28b
--- /dev/null
+++ b/Completion/Unix/Type/_texi
@@ -0,0 +1,6 @@
+#compdef -P (texi(2*|ndex))
+
+local expl
+
+_description files expl 'texinfo file'
+_files "$@" "$expl[@]" -g '*.(texinfo|texi)(-.)'
diff --git a/Completion/Unix/Type/_time_zone b/Completion/Unix/Type/_time_zone
new file mode 100644
index 000000000..cd924bbc7
--- /dev/null
+++ b/Completion/Unix/Type/_time_zone
@@ -0,0 +1,9 @@
+#compdef -value-,TZ,-default-
+
+local expl
+
+if (( ! $+_zoneinfo_dirs )); then
+  _zoneinfo_dirs=( /usr/{share,lib,share/lib}/{zoneinfo*,locale/TZ}(/) )
+fi
+
+_wanted time-zones expl 'time zone' _files -W _zoneinfo_dirs "$@" -