Date: Sun, 24 Sep 2000 00:00:33 +0100 From: Ben Smithurst <ben@FreeBSD.org> To: Sean-Paul Rees <sean@seanrees.com> Cc: questions@freebsd.org Subject: Re: zsh completion for /var/db/pkg Message-ID: <20000924000033.A30774@strontium.scientia.demon.co.uk> In-Reply-To: <20000923150435.A98968@seanrees.com> References: <20000923150435.A98968@seanrees.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Sean-Paul Rees wrote:
> Also, does someone have a completion for the man pages?
I think there's something do with pkg_* in the latest zsh ports, but I
could be mistaken. Hmm, it seems to be in zsh-devel, but not zsh. Take
a look anyway.
I made this for manpages, but it's _really_ ugly and slow. It also
doesn't work sometimes, but I don't care enough to have bothered fixing
it. It's better than nothing anyway.
function find_manpage() {
start=$1
choices=""
count=0
# need a colon in IFS to split $MANPATH
old_IFS="$IFS"
IFS=":$IFS"
# need this to prevent error from "no match found"
setopt nullglob
for i in ${=MANPATH}; do
for j in $i/*/${start}*; do
# strip off leading path and trailing .n.gz
choices="$choices ${${j##*/}%%.?.gz}"
let "count = count + 1"
if [[ $count -ge 100 ]]; then
break 2
fi
done
done
# turn off again
unsetopt nullglob
# put IFS back to what it was before
IFS="$old_IFS"
unset old_IFS
# set the reply array
eval reply=($choices)
# clean up variables
unset choices start count
}
compctl -K find_manpage man
--
Ben Smithurst / ben@FreeBSD.org / PGP: 0x99392F7D
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000924000033.A30774>
