cvsdist bf92281
#!/bin/sh -
cvsdist 5a7dde6
#
cvsdist 5a7dde6
# To use this filter with less, define LESSOPEN:
cvsdist 5a7dde6
# export LESSOPEN="|/usr/bin/lesspipe.sh %s"
cvsdist 5a7dde6
cvsdist 5a7dde6
lesspipe() {
cvsdist 5a7dde6
  case "$1" in
cvsdist bf92281
  *.[1-9n]|*.man|*.[1-9n].bz2|*.man.bz2|*.[1-9].gz|*.[1-9]x.gz|*.[1-9].man.gz)
cvsdist bf92281
	case "$1" in
cvsdist bf92281
		*.gz)	DECOMPRESSOR="gunzip -c" ;;
cvsdist bf92281
		*.bz2)	DECOMPRESSOR="bunzip2 -c" ;;
cvsdist bf92281
		*)	DECOMPRESSOR="cat" ;;
cvsdist bf92281
	esac
cvsdist bf92281
	if $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
cvsdist bf92281
		if echo "$1" | grep -q ^/; then	#absolute path
cvsdist bf92281
			man -- "$1" | cat -s
cvsdist bf92281
		else
cvsdist bf92281
			man -- "./$1" | cat -s
cvsdist bf92281
		fi
cvsdist bf92281
	else
cvsdist bf92281
		$DECOMPRESSOR -- "$1"
cvsdist bf92281
	fi ;;
cvsdist bf92281
  *.tar) tar tvvf "$1" ;;
cvsdist bf92281
  *.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
cvsdist add633f
  *.tar.bz2|*.tbz2) bzip2 -dc "$1" | tar tvvf - ;;
cvsdist bf92281
  *.[zZ]|*.gz) gzip -dc -- "$1" ;;
cvsdist bf92281
  *.bz2) bzip2 -dc -- "$1" ;;
cvsdist bf92281
  *.zip) zipinfo -- "$1" ;;
cvsdist add633f
  *.rpm) rpm -qpivl --changelog -- "$1" ;;
cvsdist bf92281
  *.cpi|*.cpio) cpio -itv < "$1" ;;
cvsdist 5a7dde6
  esac
cvsdist 5a7dde6
}
cvsdist 5a7dde6
cvsdist add633f
if [ -d "$1" ] ; then
cvsdist add633f
	/bin/ls -alF -- "$1"
cvsdist add633f
else
cvsdist add633f
	lesspipe "$1" 2> /dev/null
cvsdist add633f
fi