2004-09-09 07:12:13 +00:00
|
|
|
#!/bin/sh -
|
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
|
2004-09-09 07:12:13 +00:00
|
|
|
*.[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) tar tIvvf "$1" ;;
|
|
|
|
*.[zZ]|*.gz) gzip -dc -- "$1" ;;
|
|
|
|
*.bz2) bzip2 -dc -- "$1" ;;
|
|
|
|
*.zip) zipinfo -- "$1" ;;
|
|
|
|
*.rpm) rpm -qpivl -- "$1" ;;
|
|
|
|
*.cpi|*.cpio) cpio -itv < "$1" ;;
|
2004-09-09 07:11:53 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2004-09-09 07:12:13 +00:00
|
|
|
lesspipe "$1" 2> /dev/null
|