home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / aux / 3042 < prev    next >
Encoding:
Text File  |  1992-07-31  |  3.8 KB  |  172 lines

  1. Newsgroups: comp.unix.aux
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!nsisrv!jagubox!jim
  3. From: jim@jagubox.gsfc.nasa.gov (Jim Jagielski)
  4. Subject: Re: ksh man and PAGER ?
  5. Message-ID: <927@jagubox.gsfc.nasa.gov>
  6. Sender: usenet@nsisrv.gsfc.nasa.gov (Usenet)
  7. Nntp-Posting-Host: jagubox.gsfc.nasa.gov
  8. Reply-To: jim@jagubox.gsfc.nasa.gov (Jim Jagielski)
  9. Organization: NASA/Goddard Space Flight Center
  10. References: <4187@news.duke.edu>
  11. Distribution: na
  12. Date: Fri, 31 Jul 1992 13:23:00 GMT
  13. Lines: 157
  14.  
  15. weinhous@RadOnc.Duke.EDU (Marty Weinhous (guest)) writes:
  16.  
  17. >I recently (1) switched to ksh and (2) installed "less" (v 170) from
  18. >jagubox (thanks Jim).
  19.  
  20. >Now I would like "man" to use "less" rather than "more". I tried setting
  21. >PAGER to /usr/local/bin/less, but got scrambled man pages (lots of
  22. >escape characters rather than bolds, etc.). Attempts to fix this by
  23. >setting TERM to vt100 caused a chane in appearance, but not a fix.
  24.  
  25. >Would someone please tell me how to use "less" as the default pager
  26. >for "man"? As always, thanks in advance.
  27.  
  28. >- Marty
  29.  
  30. Here's the complete source for the hacked /usr/bin/man:
  31.  
  32. --------->8 cut here--------------
  33. #!/bin/sh
  34. :
  35. : man
  36. :
  37. #    @(#)Copyright Apple Computer 1987    Version 1.7 of man.sh on 91/12/16 20:04:46 (ATT 1.1)
  38. #    Catable manual entries printer
  39. #
  40.  
  41. BASE=/usr
  42.  
  43. sec=\?
  44. dir=
  45. col=
  46. cmd=
  47. entries=
  48. TTERM=
  49. mypager=
  50.  
  51. if [ "$PAGER" = "" ]
  52. then
  53.     mypager="/usr/local/bin/less -s -M -e"
  54. else
  55.     # pages such as pg need to have ul handle underlining
  56.     mypager="ul | $PAGER"
  57. fi
  58.  
  59. if [ ! -t 1 ] ; then    # If stdout is not a tty skip the pager
  60.     mypager=cat
  61. fi
  62.  
  63. #  parse options
  64.  
  65. for i in $*
  66. do case $i in
  67.  
  68.     [1-8])    sec=$i ;;
  69.     -c)    col=col ;;
  70.     -d)    dir=. ;;
  71.     -w)    cmd=w ;;
  72.     -T*)    TERM="`echo $i | sed 's/-T//'`" ;;
  73.     -12)    TTERM=-12 ;;
  74.     *)    entries="$entries $i" ;;
  75.    esac
  76. done
  77.  
  78.  
  79. #  now find the named entries
  80.  
  81. # Only need to truncate to 14 chars for System V file system.
  82. # / is now a Berkeley file system, so we only truncate when we
  83. # are not can't find the requested file.
  84.  
  85. for i in $entries; do
  86.  
  87.     if [ "$dir" = "." ]; then
  88.     if [ ! -r "$i" ]; then
  89.         ti=`expr $i : '^\(..............\).*' '|' $i`
  90.         if [ ! -r "$ti" ]; then
  91.         echo $0: $i not found >&2
  92.         exit 1
  93.         else
  94.         all="$all $ti"
  95.         fi
  96.     else 
  97.         all="$all $i"
  98.     fi
  99.  
  100.     else
  101.     cd $BASE/catman
  102.     fil="`find */man$sec/$i.* -print 2>/dev/null`"
  103.     if [ -n "$fil" ]; then
  104.         all="$all $fil"
  105.     else
  106.         fil="`find */man$sec/$i -print 2>/dev/null`"
  107.         if [ -n "$fil" ]; then
  108.         all="$all $fil"
  109.         else
  110.         ti=`expr $i : '^\(..............\).*' '|' $i`
  111.         fil="`find */man$sec/$ti -print 2>/dev/null`"
  112.         if [ -n "$fil" ]; then
  113.             all="$all $fil"
  114.         else
  115.             echo $0: $i not found >&2
  116.             exit 1
  117.         fi
  118.         fi
  119.     fi
  120.     fi
  121. done
  122.  
  123.  
  124. # fix up the terminal type option (make sure to use col, etc.)
  125.  
  126. case "$TERM$TTERM" in
  127.  
  128.     300|300s|450|37|300-12|300s-12|450-12| \
  129.         4000a|4000A|382|1620|1620-12)    post="greek -T$TERM$TTERM" ;;
  130.     hp|2621|2645|2640)    col=col; post="greek -T$TERM$TTERM" ;;
  131.     4014|tek)    post="greek -T$TERM$TTERM" ;;
  132.     X97)        col=col; post=xerox ;;
  133.     *)        col=col; post=cat ;;
  134. esac
  135.  
  136. if [ "$col" != "" ]
  137.    then post="$col | $post"
  138. fi
  139.  
  140.  
  141. # now print the pages
  142. # First export TERM, which you need to do if you use -T
  143. export TERM
  144.  
  145. if [ "$cmd" = "w" ]
  146.  
  147.    then    echo $all
  148.     exit 0
  149.  
  150.    else    for i in $all
  151.  
  152.     do case $i in
  153.  
  154.         *.z)    eval "pcat $i | $post | $mypager" ;;
  155.         *.Z)    eval "zcat $i | $post | $mypager" ;;
  156.         *)    eval "cat $i | $post | $mypager" ;;
  157.  
  158.        esac
  159.     done
  160.  
  161. fi
  162. --------->8 cut here--------------
  163. -- 
  164. ==============================================================================
  165. #include <std/disclaimer.h>
  166.  
  167.                 Jim Jagielski                  NASA/GSFC, Code 734.4
  168.           jim@jagubox.gsfc.nasa.gov             Greenbelt, MD 20771
  169.  
  170.            "The great scallop... this tatty, scrofulous old rapist,
  171.                is second in depravity only to the common clam."
  172.