Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: man page completion / regexp

looks rather complicated to me
Here's my solution for Solaris only:
(part of .zprofile)
MNPG="'"`echo $MANPATH|awk -F: '{for(i=1;i<=NF;i++)printf("%s/*/*(:t)
compctl -g $MNPG man


>>> Jarkko Maja <jarkko1982@xxxxxxxxx> 06.06.2004 12:09:44 >>>

I'm have in my zsh-4.0.7 ~/.zshrc the following for
man page completion:

# man page completion
man_glob () {
         local a b manp cat
         read -cA a
         read -lA b
         manp=`manpath 2> /dev/null` || manp=`echo
         [[ "$OSTYPE" = *bsd* ]] && cat=,cat
         if [[ "$a[2]" = [0-9nlpo](|p) ]] # && [[ -n
"$a[3]" || "${(M)b% 
}" = " " ]]
                 reply=( ${^$(echo $manp | sed -e
/g')}/{man,sman$cat}$a[2]/$1*(-N.:t) )
                 reply=( ${^$(echo $manp | sed -e
/g')}/{man,sman$cat}[0-9nlpo]{,X,m}*/$1*(-N.:t) )
         reply=( ${reply%.[^0-9Xmnlpo]*} )
         # Uncomment to strip trailing section names
from reply
         #reply=( ${reply%.[0-9Xmnlpo]*} )
compctl -K man_glob -x 'C[-1,-P]' -m - \
         'R[-*l*,;]' -g '*.(man|[0-9Xmnlpo](|[a-z]))'
-- + -f -g '..' man

# Uncomment to accept man page names with trailing
section names, e.g., 
man () {
         local test=${(M)@#*/} # File name probably
contains a slash
         if [[ -z "$test" ]] && [[ $# -lt 3 ]]
                 command man 
                 command man "$@"

This works perfect in Linux/*BSD/Solaris. E.g., man
locale[TAB] gives: locale.1 locale.5 locale.7 etc and
man locale.7 becomes man 7 locale. And man 7
locale[TAB] shows only locale.7. However, with newer
versions of Linux's man-pages package there are also
sections like 0p, 1p, 3p and, e.g., man man.1p becomes
man 1 man. So, to overcome this, I got man 1p man by

command man

But then I have problem because man 
X509_NAME_ENTRY_create_by_NID.3ssl becomes to man l 
X509_NAME_ENTRY_create_by_NID and previously it was
correctly man 3 ... Also there man pages in dir
man/man3 like LWP.3pm.

Any hints are welcome, I've pretty much tested
everything I can imagine. If you can get this working,
I'd be delighted to know how to fix this!

Thanks in advance.

Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.

Messages sorted by: Reverse Date, Date, Thread, Author