[Home] Zsh logo

manpath

Zsh Wizard

Download manpath Return to Examples
  1. #!zsh -f
  2. # Here's a little zsh script that I call "manpath". You give it a
  3. # single argument, and it searches for man pages whose names contain
  4. # that argument. It searches all the directories named in your
  5. # "manpath" environment variable.
  6. #
  7. # For instance, "manpath wait" prints this on my HP700:
  8. #
  9. # -r--r--r-- 1 root root 6652 Sep 2 1993 /usr/local/man/mann/tkwait.n
  10. # -r--r--r-- 1 bin bin 1202 Sep 23 1993 /usr/man/man1.Z/wait.1
  11. # -r--r--r-- 3 bin bin 4739 Sep 10 1992 /usr/man/man2.Z/wait.2
  12. # -r--r--r-- 3 bin bin 4739 Sep 10 1992 /usr/man/man2.Z/wait3.2
  13. # -r--r--r-- 3 bin bin 4739 Sep 10 1992 /usr/man/man2.Z/waitpid.2
  14. # -r--r--r-- 1 bin bin 2440 Sep 10 1992 /usr/man/man3.Z/await_event.3g
  15. # -r--r--r-- 1 bin bin 1627 Sep 10 1992 /usr/man/man3.Z/await_retra.3g
  16. # -r--r--r-- 1 bin bin 2136 Sep 10 1992 /usr/man/man3.Z/hpib_wait_o.3i
  17. # -r--r--r-- 1 bin bin 816 Sep 10 1992 /usr/man/man3.Z/wait.3f
  18. # -rw-rw-rw- 1 franl code 1201 Mar 23 13:06 /usr/man/cat1.Z/wait.1
  19. # -rw-rw-rw- 1 franl code 6146 Mar 23 13:06 /usr/man/cat2.Z/wait.2
  20. [[ ! -o nonomatch ]] && setopt nonomatch
  21. if (($# == 0))
  22. then
  23. echo $manpath | tr " " "\012"
  24. else
  25. for dir in $manpath
  26. do
  27. for subdir in $dir/man* $dir/cat*
  28. do
  29. /bin/ls -l $subdir/*$1*
  30. done
  31. done |& egrep -v '([Nn]o(t found| such|t a))'
  32. fi