X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/499a48f31a6b81c695b7270fc474299c029669c1..285a138691b40d6d20931676cc9f2fdb52fe6737:/lesspipe.sh diff --git a/lesspipe.sh b/lesspipe.sh new file mode 100755 index 0000000..70d76d3 --- /dev/null +++ b/lesspipe.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# This is a preprocessor for 'less'. It is used when this environment +# variable is set: LESSOPEN="|lesspipe.sh %s" + +lesspipe() { + case "$1" in + *.tar) tar tvvf $1 2>/dev/null ;; # View contents of .tar and .tgz files + *.tgz|*.tar.gz|*.tar.Z|*.tar.z) gzip -dc $1 | tar tvvf - 2>/dev/null ;; + *.tar.bz2) bzip2 -dc $1 | tar tvvf - 2>/dev/null ;; + *.zip) unzip -l $1 2>/dev/null ;; + *.[1-9n]|*.man) + groff -te -Tascii -mandoc $1 ;; + *.[1-9].gz|*.man.gz) + gzip -dc $1 | groff -te -Tascii -mandoc ;; + *.Z|*.z|*.gz) gzip -dc $1 2>/dev/null ;; # View compressed files correctly + *.bz2) bzip2 -dc $1 2>/dev/null ;; # View compressed files correctly +# *) FILE=`file -L $1` ; # Check to see if binary, if so -- view with 'strings' +# FILE1=`echo $FILE | cut -d ' ' -f 2` +# FILE2=`echo $FILE | cut -d ' ' -f 3` +# if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \ +# -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then +# strings $1 +# fi ;; + esac +} + +lesspipe $1