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

Re: completion control for "man" command


On Sat, Jun 13, 1998 at 08:40:12PM +0200, Sven Guckes wrote:

> Hey!
> Rather than keeping this mail to myself and trying the impossible [;-)] I'll
> forward this to the experts on the zsh-users mailist. Hope you don't mind.
> (And I hope it answers your question on a "public forum" for zsh, Johan. :-)
> I wonder - hasn't the completion control for manuals been perfected by now?
> Sven
[message on "how do I complete manpages?" deleted]

I use the following for man completion. It uses a file ~/tmp/_man_ which
stores the filenames in question. If you don't like your loginshell to
wait for the creation of the file every now and then (I use 14 days)
because it creates the _man_-file, just make a cronjob out of this...

------------------------------ snip ~/.zshrc ------------------------------
# completion for manpages
# if ~/tmp/_man_ is too old then remove it and create a new one later
find ~/tmp -mtime 14 -name "_man_" -exec rm -f {} \;

createman () {
   echo "creating ~/tmp/_man_"
   # search the filenames which should be included later...
   find /usr/man -type f > ~/tmp/_man_
   find /usr/local/man -type f >> ~/tmp/_man_
   find /usr/X11R6/man -type f >> ~/tmp/_man_
   # remove pathname, .gz-suffix and the section-number, use sort & uniq
   # to get an ordered list of filenames
   sed -e "s/.*\///" -e "s/\.gz//" -e "s/\.[^.]*$//" ~/tmp/_man_ | sort | uniq > ~/tmp/_man2_
   rm -f ~/tmp/_man_
   # put all on one line
   (for i in `cat ~/tmp/_man2_` ; do echo -n "$i " ; done) > ~/tmp/_man_
   rm -f ~/tmp/_man2_
# create ~/tmp/_man_
if [ ! -f ~/tmp/_man_ ] ; then createman ; fi

# invoke compctl on file list
man_pages=(`cat ~/tmp/_man_`)
compctl -f -k man_pages man
------------------------------ snip ~/.zshrc ------------------------------


    Thomas Köhler    Email:     jean-luc@xxxxxxxxxxxxxxxxx
        <><           WWW:    http://home.pages.de/~jeanluc/
                      IRC:               jeanluc
      LCARS --- Linux for Computers on All Real Starships

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