From: Tanaka Akira <akr@jaist.ac.jp>
To: Zsh workers <zsh-workers@sunsite.auc.dk>
Subject: Re: _urls ... and CVS
Date: 16 Oct 1999 14:18:33 +0900 [thread overview]
Message-ID: <rsqyad33mty.fsf@crane.jaist.ac.jp> (raw)
In-Reply-To: Adam Spiers's message of "Fri, 15 Oct 1999 17:54:07 +0100"
In article <19991015175407.A19450@thelonious.new.ox.ac.uk>,
Adam Spiers <adam@thelonious.new.ox.ac.uk> writes:
> Can some kind person please email me correctly-patched _urls? Mine
> got badly messed up somehow.
This is my latest version.
#compdef curl
# Usage: _urls [-f]
# Options:
# -f : complete files first.
#
# Configuration keys used:
#
# urls_path
# 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.auc.dk
# ... drwxr-xr-x ... 512 Sep 3 02:48 ./http/sunsite.auc.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.auc.dk/zsh/
# % cat bookmark/zsh/meta
# http://www.zsh.org/
#
# urls_localhttp
# Specify a local web server in the form:
# 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. compconf urls_localhttp=www:/usr/local/apache/htdocs:public_html
setopt localoptions extendedglob
local ipre scheme host user hosts ret=1 expl
local urls_path="${compconfig[urls_path]:-${ZDOTDIR:-$HOME}/.zsh/urls}"
local localhttp_servername="${${(@s.:.)compconfig[urls_localhttp]}[1]}"
local localhttp_documentroot="${${(@s.:.)compconfig[urls_localhttp]}[2]}"
local localhttp_userdir="${${(@s.:.)compconfig[urls_localhttp]}[3]}"
if [[ "$1" = -f ]]; then
shift
_files "$@" && return
fi
ipre="$IPREFIX"
if ! compset -P '(#b)([-+.a-z0-9]#):'; then
_description expl 'URL prefix'
[[ -d $urls_path/bookmark ]] &&
compadd "$@" "$expl[@]" -S '' bookmark: && ret=0
compadd "$@" "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0
return $ret
fi
scheme="$match[1]"
case "$scheme" in
http|ftp|gopher)
if ! compset -P //; then
compadd "$@" -S '' //
return
fi
;;
file)
if ! compset -P //; then
if [[ -prefix / ]]; then
_path_files "$@" -S '' -g '*(^/)' && ret=0
_path_files "$@" -S/ -r '/' -/ && ret=0
elif [[ -z "$PREFIX" ]]; then
compadd -S '/' -r '/' - "${PWD%/}"
ret=0
fi
return $ret
fi
;;
bookmark)
if [[ -f "$urls_path/$scheme/$PREFIX$SUFFIX" &&
-s "$urls_path/$scheme/$PREFIX$SUFFIX" ]]; then
compadd "$@" -QU -- "$ipre$(<"$urls_path/$scheme/$PREFIX$SUFFIX")" && ret=0
else
_description expl 'bookmark'
_path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && ret=0
_path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0
fi
return $ret
;;
esac
# Complete hosts
if ! compset -P '(#b)([^/]#)/'; then
hosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t))
(( $#hosts )) || _hosts -S/ && ret=0
[[ "$scheme" = http ]] && hosts=($hosts $localhttp_servername)
compadd "$@" -QS/ - $hosts && ret=0
return $ret
fi
host="$match[1]"
# Complete part after hostname
if [[ "$localhttp_servername" = "$host" ]]; then
if compset -P \~; then
if ! compset -P '(#b)([^/]#)/'; then
_users -S/
return
fi
user="$match[1]"
_path_files -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0
_path_files -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0
else
_path_files -W $localhttp_documentroot -g '*(^/)' && ret=0
_path_files -W $localhttp_documentroot -S/ -r '/' -/ && ret=0
fi
else
_path_files -W $urls_path/$scheme/$host -g '*(^/)' && ret=0
_path_files -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0
fi
return $ret
--
Tanaka Akira
next prev parent reply other threads:[~1999-10-16 5:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-15 12:10 PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Sven Wischnowsky
1999-10-15 15:30 ` Oliver Kiddle
[not found] ` <991015155008.ZM24081@candle.brasslantern.com>
1999-10-15 16:05 ` Oliver Kiddle
1999-10-15 16:40 ` Bart Schaefer
1999-10-15 16:54 ` _urls ... and CVS Adam Spiers
1999-10-16 5:18 ` Tanaka Akira [this message]
1999-10-16 13:56 ` PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Tanaka Akira
1999-10-16 15:33 ` "[[" (Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)) Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=rsqyad33mty.fsf@crane.jaist.ac.jp \
--to=akr@jaist.ac.jp \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).