about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2001-10-12 10:43:29 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2001-10-12 10:43:29 +0000
commit0c71c4fa7744754b1b730e37bcc2fcdb49e5f6a7 (patch)
treef00181ab2895821f4e39322d7c21925f3122fedf
parent2493d1ef19162ac05ba496e0bb387151f09aa1a4 (diff)
downloadzsh-0c71c4fa7744754b1b730e37bcc2fcdb49e5f6a7.tar.gz
zsh-0c71c4fa7744754b1b730e37bcc2fcdb49e5f6a7.tar.xz
zsh-0c71c4fa7744754b1b730e37bcc2fcdb49e5f6a7.zip
_sysctl for darwin, _webbrowser for galeon etc (15983)
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_sysctl4
-rw-r--r--Completion/Unix/Command/_user_admin2
-rw-r--r--Completion/Unix/Command/_webbrowser3
-rw-r--r--Completion/Unix/Type/_urls187
5 files changed, 198 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c0a25463b..d646c62fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2001-10-12  Oliver Kiddle  <opk@zsh.org>
 
+	* 15983: Completion/Unix/Command/_user_admin,
+	Completion/Unix/Command/_sysctl, Completion/Unix/Type/_urls,
+	Completion/Unix/Command/_webbrowser: darwin support in _sysctl,
+	complete files for galeon
+
 	* 16018: acconfig.h, zshconfig.ac, Etc/MACHINES,
 	Test/C02cond.ztst: allow dynamic loading to work on MacOS X
 	if the dlcompat library is installed.
diff --git a/Completion/Unix/Command/_sysctl b/Completion/Unix/Command/_sysctl
index bda6a5ac2..2198d1b8a 100644
--- a/Completion/Unix/Command/_sysctl
+++ b/Completion/Unix/Command/_sysctl
@@ -13,8 +13,8 @@ case $OSTYPE in
       '(-o)-x[show opaques as well (entire values)]' \
       '(-a)*:sysctl variable:_multi_parts -i . sysctlvars'
   ;;
-  freebsd[0-4].*)
-    : ${(A)_cache_sysctlvars:=${${$(sysctl -A):#[^a-z]*}%%:*}}
+  freebsd[0-4].*|darwin*)
+    : ${(A)_cache_sysctlvars:=${${$(sysctl -A 2>/dev/null):#[^a-z]*}%%:*}}
     _arguments -s -A "-*" \
       '(-w -X *)-a[list all]' \
       '(-w -X *)-A[show all opaques (values suppressed)]' \
diff --git a/Completion/Unix/Command/_user_admin b/Completion/Unix/Command/_user_admin
index 5b467ab18..bf0908372 100644
--- a/Completion/Unix/Command/_user_admin
+++ b/Completion/Unix/Command/_user_admin
@@ -19,7 +19,7 @@ if [[ $service = user* ]]; then
     '(-D)-f+[specify inactive days]:inactive days'
     '(-D)-g+[initial group]:initial group:_groups'
     '(-D)-G+[supplementary groups]:supplementary groups:_groups -S,'
-    "(-D)-s+[shell]:shell:( $shells /dev/null )"
+    "(-D)-s+[shell]:shell:( $shells /bin/false )"
     '(-D -M)-m[create home directory]'
     '(-D)-u[uid]:uid'
     '(-D)-o[allow non unique uid]'
diff --git a/Completion/Unix/Command/_webbrowser b/Completion/Unix/Command/_webbrowser
new file mode 100644
index 000000000..b0e6b1c21
--- /dev/null
+++ b/Completion/Unix/Command/_webbrowser
@@ -0,0 +1,3 @@
+#compdef amaya arena chimera express grail gzilla hotjava mmm mozilla opera www xmosaic Mosaic galeon
+
+_urls -f
diff --git a/Completion/Unix/Type/_urls b/Completion/Unix/Type/_urls
new file mode 100644
index 000000000..63ab0e7c1
--- /dev/null
+++ b/Completion/Unix/Type/_urls
@@ -0,0 +1,187 @@
+#compdef curl
+
+# Usage: _urls [-f]
+# Options:
+#  -f : complete files first.
+#
+# Configuration styles used:
+#
+#  urls
+#    The path to a directory containing a URL database, such as:
+#
+#      % cd ~/.zsh/urls
+#      % find . -ls
+#      ... drwxr-xr-x ... 512 Sep  3 02:46 .
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http
+#      ... drwxr-xr-x ... 512 Sep  3 02:52 ./http/www.zsh.org
+#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla
+#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers
+#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999
+#      ... -rw-r--r-- ...   0 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999/index.html
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.dk
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.dk/zsh
+#      ... drwxr-xr-x ... 512 Sep  3 02:47 ./bookmark
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./bookmark/zsh
+#      ... -rw-r--r-- ...  27 Sep  3 02:47 ./bookmark/zsh/home
+#      ... -rw-r--r-- ...  20 Sep  3 02:48 ./bookmark/zsh/meta
+#      % cat bookmark/zsh/home 
+#      http://sunsite.dk/zsh/
+#      % cat bookmark/zsh/meta
+#      http://www.zsh.org/
+#
+#    Alternatively it may contain the path to a normal file and the URLs will
+#    be taken from that.  Or the style may contain the URLs as its values.
+#
+#  local
+#    Specify a local web server as an array with three elements:
+#      <hostname> <doc root> <user area>
+#    where hostname is the name of the web server, doc root is the path to
+#    the default web pages for the server and user area is the directory
+#    name used by a user placing web pages within their home area.
+#    E.g.:
+#      zstyle ':completion:*:urls' local www /usr/local/apache/htdocs public_html
+
+local ipre scheme host user uhosts ret=1 expl match glob suf
+local localhttp
+zstyle -a ":completion:${curcontext}:urls" local localhttp
+local localhttp_servername="$localhttp[1]"
+local localhttp_documentroot="$localhttp[2]"
+local localhttp_userdir="$localhttp[3]"
+
+if [[ "$1" = -f ]]; then
+  shift
+  _wanted -C -f files expl file _files "$@" && return 0
+fi
+
+zstyle -a ":completion:${curcontext}:urls" urls urls
+
+if [[ $#urls -gt 1 || ( $#urls -eq 1 && ! -d $urls[1] ) ]]; then
+  [[ $#urls -eq 1 && -f $urls[1] ]] && urls=( $(< $urls[1]) )
+  _wanted urls expl 'urls' compadd -a urls && return 0
+  urls=()
+fi
+
+urls="$urls[1]"
+
+glob=(-g '*(^/)')
+zparseopts -D -K -E 'g:=glob'
+
+ipre="$IPREFIX"
+
+if ! compset -P '(#b)([-+.a-z0-9]#):'; then
+  _tags -C argument prefixes
+  while _tags; do
+    while _next_label prefixes expl 'URL prefix' -S '' "$@"; do
+      compset -S '[^:/]*' && compstate[to_end]=''
+      [[ -d $urls/bookmark ]] &&
+        compadd "$expl[@]" bookmark: && ret=0
+      compadd "$expl[@]" file: ftp:// gopher:// http:// && ret=0
+    done
+    (( ret )) || return 0
+  done
+  return 1
+fi
+scheme="$match[1]"
+
+case "$scheme" in
+  http|ftp|gopher)
+    if ! compset -P //; then
+      _wanted -C "$scheme" prefixes expl 'end of prefix' compadd -S '' "$@" //
+      return
+    fi
+  ;;
+  file)
+    if ! compset -P //; then
+      _tags -C file files
+      while _tags; do
+        while _next_label files expl 'local file'; do
+          if [[ -prefix / ]]; then
+	    _path_files "$expl[@]" -S '' "${glob[@]}" && ret=0
+	    _path_files "$expl[@]" -S/ -r '/' -/ && ret=0
+          elif [[ -z "$PREFIX" ]]; then
+	    compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0
+          fi
+        done
+	(( ret )) || return 0
+      done
+      return 1
+    fi
+  ;;
+  bookmark)
+    if [[ -f "$urls/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" &&
+	  -s "$urls/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" ]]; then
+      _wanted -C bookmark bookmarks expl bookmarks \
+          compadd "$@" -U - \
+              "$ipre$(<"$urls/$scheme/${(Q)PREFIX}${(Q)SUFFIX}")" && ret=0
+    else
+      _tags -C bookmark files
+      while _tags; do
+        while _next_label files expl 'bookmark'; do
+          _path_files -W "$urls/$scheme" "$expl[@]" -S '' "${glob[@]}" && 
+              ret=0
+          _path_files -W "$urls/$scheme" -S/ -r '/' "$expl[@]" -/ && ret=0
+        done
+	(( ret )) || return 0
+      done
+    fi
+    return ret
+  ;;
+esac
+
+# Complete hosts
+if ! compset -P '(#b)([^:/]#)([:/])'; then
+  uhosts=($urls/$scheme/$PREFIX*$SUFFIX(/:t))
+
+  _tags hosts
+  while _tags; do
+    while _next_label hosts expl host "$@"; do
+      compset -S '[:/]*' || suf="/"
+      (( $#uhosts )) || _hosts -S "$suf" -r '/:' "$expl[@]" && ret=0
+      [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
+      compadd -S "$suf" -r '/:' "$expl[@]" -a uhosts && ret=0
+    done
+    (( ret )) || return 0
+  done
+  return 1
+fi
+host="$match[1]"
+
+[[ $match[2] = ':' ]] && ! compset -P '<->/' && _message 'port number' && return 0
+
+# Complete part after hostname
+
+_tags -C local files || return 1
+
+if [[ "$localhttp_servername" = "$host" ]]; then
+  if compset -P \~; then
+    if ! compset -P '(#b)([^/]#)/'; then
+      _users -S/ "$@"
+      return
+    fi
+    user="$match[1]"
+    while _tags; do
+      while _next_label files expl 'local file'; do
+        _path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir "${glob[@]}" && ret=0
+        _path_files -S/ -r '/'  "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0
+      done
+      (( ret )) || return 0
+    done
+  else
+    while _tags; do
+      while _next_label files expl 'local file'; do
+        _path_files "$expl[@]" "$@" -W $localhttp_documentroot "${glob[@]}" && ret=0
+        _path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0
+      done
+      (( ret )) || return 0
+    done
+  fi
+else
+  while _tags; do
+    while _next_label files expl 'local file'; do
+      _path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
+      _path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
+    done
+    (( ret )) || return 0
+  done
+fi
+return $ret