home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 1999 May / CDROM.ISO / suse / inst-sys / usr / bin / lesspipe.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1999-03-18  |  1.1 KB  |  33 lines

  1. #!/bin/sh
  2. # This is a preprocessor for 'less'.  It is used when this environment
  3. # variable is set:   LESSOPEN="|lesspipe.sh %s"
  4.  
  5. lesspipe() {
  6.   case "$1" in
  7.   *.tar) tar tvvf $1 2>/dev/null ;; # View contents of .tar and .tgz files
  8.   *.tgz) tar tzvvf $1 2>/dev/null ;;
  9.   *.tar.gz) tar tzvvf $1 2>/dev/null ;;
  10.   *.tar.Z) tar tzvvf $1 2>/dev/null ;;
  11.   *.tar.z) tar tzvvf $1 2>/dev/null ;;
  12.   *.Z) gzip -dc $1  2>/dev/null ;; # View compressed files correctly
  13.   *.z) gzip -dc $1  2>/dev/null ;;
  14.   *.gz) gzip -dc $1  2>/dev/null ;;
  15.   *.zip) unzip -l $1 2>/dev/null ;;
  16.   *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.man) FILE=`file -L $1` ; # groff src
  17.     FILE=`echo $FILE | cut -d ' ' -f 2`
  18.     if [ "$FILE" = "troff" ]; then
  19.       groff -s -p -t -e -Tascii -mandoc $1
  20.     fi ;;
  21.   *.ms) groff -Tascii -ms $1 2>/dev/null ;;
  22. #  *) FILE=`file -L $1` ; # Check to see if binary, if so -- view with 'strings'
  23. #    FILE1=`echo $FILE | cut -d ' ' -f 2`
  24. #    FILE2=`echo $FILE | cut -d ' ' -f 3`
  25. #    if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \
  26. #         -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then
  27. #      strings $1
  28. #    fi ;;
  29.   esac
  30. }
  31.  
  32. lesspipe $1
  33.