lesspipe.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! /bin/sh -
  2. # Preprocessor for 'less'.
  3. #
  4. # Copyright (c) 2017 Antonio Diaz Diaz, <antonio@gnu.org>.
  5. # Copyright (c) 2017 Matias Fonzo, <selk@dragora.org>.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. # Use with environment variable: LESSOPEN="|lesspipe.sh %s"
  19. case $1 in
  20. *.tar)
  21. tar -tvvf "$1" 2> /dev/null
  22. ;;
  23. *.tbz2 | *.tar.bz2)
  24. bzip2 -cd "$1" 2> /dev/null | tar -tvvf - 2> /dev/null
  25. ;;
  26. *.t[ag]z | *.tar.gz | *.tar.[zZ])
  27. tar -tzvvf "$1" 2> /dev/null
  28. ;;
  29. *.tlz | *.tar.lz)
  30. lzip -cd "$1" 2> /dev/null | tar -tvvf - 2> /dev/null
  31. ;;
  32. *.txz | *.tar.xz)
  33. xz -cd "$1" 2> /dev/null | tar -tvvf - 2> /dev/null
  34. ;;
  35. *.zip)
  36. unzip -l "$1" 2> /dev/null
  37. ;;
  38. *.[1-9n])
  39. nroff -mandoc "$1"
  40. ;;
  41. *.[1-9n].bz2)
  42. bzip2 -cd "$1" 2> /dev/null | nroff -mandoc -
  43. ;;
  44. *.[1-9n].gz)
  45. gzip -cd "$1" 2> /dev/null | nroff -mandoc -
  46. ;;
  47. *.[1-9n].lz)
  48. lzip -cd "$1" 2> /dev/null | nroff -mandoc -
  49. ;;
  50. *.bz2)
  51. bzip2 -cd "$1" 2> /dev/null
  52. ;;
  53. *.gz | *.[zZ])
  54. gzip -cd "$1" 2> /dev/null
  55. ;;
  56. *.lz)
  57. lzip -cd "$1" 2> /dev/null
  58. ;;
  59. *.xz)
  60. xz -cd "$1" 2> /dev/null
  61. ;;
  62. esac