less/lesspipe.sh

52 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/sh -
auto-import changelog data from less-358-7.src.rpm Wed Aug 23 2000 Bernhard Rosenkraenzer <bero@redhat.com> - support files with spaces in their names (Bug #16777) Tue Aug 08 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Support gzipped man pages in lesspipe.sh (Bug #15610) Thu Aug 03 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Tweak init script (Bug #14622) Thu Jul 27 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Oops, actually apply the patch for 9443. ;) Wed Jul 26 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Fix up messed output if a user outputs anything in ~/.bashrc or the likes (Bug #9443) - handle RPM_OPT_FLAGS Thu Jul 13 2000 Prospector <bugzilla@redhat.com> - automatic rebuild Thu Jul 13 2000 Bernhard Rosenkraenzer <bero@redhat.com> - 358 Mon Jun 26 2000 Matt Wilson <msw@redhat.com> - defattr root Mon Jun 19 2000 Bernhard Rosenkraenzer <bero@redhat.com> - FHSify Fri Apr 14 2000 Bernhard Rosenkraenzer <bero@redhat.com> - 354 Mon Mar 20 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Update to v352 Tue Mar 07 2000 Jeff Johnson <jbj@redhat.com> - rebuild for sparc baud rates > 38400. Tue Jan 25 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Update to v346 - Update download URL - use the configure marcro - strip binary - fix up lesspipe stuff (Bug #8750 and a couple of non-reported bugs) (Karsten, did I mention I'll kill you when you return from SAP? ;) ) Fri Jan 07 2000 Karsten Hopp <karsten@redhat.de> - added lesspipe.sh to show listings of package contents instead of binary output. Fri Aug 27 1999 Preston Brown <pbrown@redhat.com> - less finally gets maintenance, upgraded to 340 Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> - auto rebuild in the new build environment (release 6) Tue Mar 16 1999 Preston Brown <pbrown@redhat.com> - removed ifarch axp stuff for /bin/more, more now works on alpha properly. Wed Feb 24 1999 Preston Brown <pbrown@redhat.com> - Injected new description and group. Fri Dec 18 1998 Preston Brown <pbrown@redhat.com> - bumped spec number for initial rh 6.0 build Thu May 07 1998 Prospector System <bugs@redhat.com> - translations modified for de, fr, tr Wed Apr 08 1998 Cristian Gafton <gafton@redhat.com> - updated to 332 and built for Manhattan - added buildroot Mon Jun 02 1997 Erik Troan <ewt@redhat.com> - built against glibc
2004-09-09 07:11:53 +00:00
#
# To use this filter with less, define LESSOPEN:
# export LESSOPEN="|/usr/bin/lesspipe.sh %s"
lesspipe() {
case "$1" in
*.[1-9n]|*.man|*.[1-9n].bz2|*.man.bz2|*.[1-9].gz|*.[1-9]x.gz|*.[1-9].man.gz)
case "$1" in
*.gz) DECOMPRESSOR="gunzip -c" ;;
*.bz2) DECOMPRESSOR="bunzip2 -c" ;;
*) DECOMPRESSOR="cat" ;;
esac
if $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
if echo "$1" | grep -q ^/; then #absolute path
man -- "$1" | cat -s
else
man -- "./$1" | cat -s
fi
else
$DECOMPRESSOR -- "$1"
fi ;;
*.tar) tar tvvf "$1" ;;
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
*.tar.bz2|*.tbz2) bzip2 -dc "$1" | tar tvvf - ;;
*.[zZ]|*.gz) gzip -dc -- "$1" ;;
*.bz2) bzip2 -dc -- "$1" ;;
*.zip) zipinfo -- "$1" ;;
*.rpm) rpm -qpivl --changelog -- "$1" ;;
*.cpi|*.cpio) cpio -itv < "$1" ;;
*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
if [ -x "`which identify`" ]; then
identify "$1"
else
echo "No identify available"
echo "Install ImageMagick to browse images"
fi ;;
*)
case "$1" in
*.gz) DECOMPRESSOR="gunzip -c" ;;
*.bz2) DECOMPRESSOR="bunzip2 -c" ;;
esac
$DECOMPRESSOR -- "$1" ;;
auto-import changelog data from less-358-7.src.rpm Wed Aug 23 2000 Bernhard Rosenkraenzer <bero@redhat.com> - support files with spaces in their names (Bug #16777) Tue Aug 08 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Support gzipped man pages in lesspipe.sh (Bug #15610) Thu Aug 03 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Tweak init script (Bug #14622) Thu Jul 27 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Oops, actually apply the patch for 9443. ;) Wed Jul 26 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Fix up messed output if a user outputs anything in ~/.bashrc or the likes (Bug #9443) - handle RPM_OPT_FLAGS Thu Jul 13 2000 Prospector <bugzilla@redhat.com> - automatic rebuild Thu Jul 13 2000 Bernhard Rosenkraenzer <bero@redhat.com> - 358 Mon Jun 26 2000 Matt Wilson <msw@redhat.com> - defattr root Mon Jun 19 2000 Bernhard Rosenkraenzer <bero@redhat.com> - FHSify Fri Apr 14 2000 Bernhard Rosenkraenzer <bero@redhat.com> - 354 Mon Mar 20 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Update to v352 Tue Mar 07 2000 Jeff Johnson <jbj@redhat.com> - rebuild for sparc baud rates > 38400. Tue Jan 25 2000 Bernhard Rosenkraenzer <bero@redhat.com> - Update to v346 - Update download URL - use the configure marcro - strip binary - fix up lesspipe stuff (Bug #8750 and a couple of non-reported bugs) (Karsten, did I mention I'll kill you when you return from SAP? ;) ) Fri Jan 07 2000 Karsten Hopp <karsten@redhat.de> - added lesspipe.sh to show listings of package contents instead of binary output. Fri Aug 27 1999 Preston Brown <pbrown@redhat.com> - less finally gets maintenance, upgraded to 340 Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> - auto rebuild in the new build environment (release 6) Tue Mar 16 1999 Preston Brown <pbrown@redhat.com> - removed ifarch axp stuff for /bin/more, more now works on alpha properly. Wed Feb 24 1999 Preston Brown <pbrown@redhat.com> - Injected new description and group. Fri Dec 18 1998 Preston Brown <pbrown@redhat.com> - bumped spec number for initial rh 6.0 build Thu May 07 1998 Prospector System <bugs@redhat.com> - translations modified for de, fr, tr Wed Apr 08 1998 Cristian Gafton <gafton@redhat.com> - updated to 332 and built for Manhattan - added buildroot Mon Jun 02 1997 Erik Troan <ewt@redhat.com> - built against glibc
2004-09-09 07:11:53 +00:00
esac
}
if [ -d "$1" ] ; then
/bin/ls -alF -- "$1"
else
lesspipe "$1" 2> /dev/null
fi