home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / less / LESSOPEN / __headers__.txt
Encoding:
Text File  |  2008-02-01  |  2.0 KB  |  44 lines

  1.        You  may  define an "input preprocessor" for less.  Before       less opens a file, it first gives your input  preprocessor       a  chance  to  modify the way the contents of the file are       displayed.
  2.  
  3. What this means is that less(1) can automatically open up tar files,
  4. uncompress gzipped files, and even display something reasonable for
  5. graphics files.
  6.  
  7. You just need to put the following in your
  8. .zlogin/.login/.bash_profile/whatever:
  9.  
  10. eval $(lesspipe)
  11. or
  12. eval $(lessfile)
  13.  
  14. lesspipe will toss the contents/info on stdout and less will read them
  15. as they come across.  This means that you don't have to wait for the
  16. decoding to finish before less shows you the file.  This also means that
  17. you'll get a 'byte N' instead of an N% as your file position.  You can
  18. seek to the end and back to get the N% but that means you have to wait
  19. for the pipe to finish.
  20.  
  21. lessfile will toss the contents/info on a file which less will then
  22. read.  After you're done, lessfile will then delete the file.  This
  23. means that the process has to finish before you see it, but you get nice
  24. percentages (N%) up front.
  25.  
  26. If you have some additional tests for binary files that I don't handle, go
  27. ahead and send them to me.  Note that I will never integrate commands
  28. for text files.  If you want to add man-ifying or html-izing commands to 
  29. your copy of lesspipe, go ahead, they just won't be integrated in the
  30. main distribution.
  31.  
  32. Here are two additional tests that you might like to use but aren't in
  33. the lesspipe script due to speed or principle of least surprise.
  34.  
  35.     # Decode directories:    if [ -d "$1" ]; then    echo "$1:"; ls -l $1    else
  36.  
  37.     # view strings inside of an executable    if [ -x "$1" ]; then        type=$(file "$1")        case "$type" in           *executable* )            echo -e "$type\n"            strings "$1"            ;;        esac    fi
  38.  
  39. These two entries courtesy of Adrian Bridgett <adrian.bridgett@poboxes.com>.
  40. Please send in your entries as well.
  41.  
  42. If you have any questions, send me e-mail at <torin@daft.com>.
  43. Mentioning less in the subject line will help.
  44.