diff options
author | Mike Frysinger <vapier@gentoo.org> | 2008-04-16 17:33:38 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2008-04-16 17:33:38 +0000 |
commit | 94af298b3754ee50ad1c7ed08c0b4072a9b3d8b9 (patch) | |
tree | beda0b9baf8ad2de7dc9444742723d16aca8e37d /sys-apps/less | |
parent | old (diff) | |
download | historical-94af298b3754ee50ad1c7ed08c0b4072a9b3d8b9.tar.gz historical-94af298b3754ee50ad1c7ed08c0b4072a9b3d8b9.tar.bz2 historical-94af298b3754ee50ad1c7ed08c0b4072a9b3d8b9.zip |
steal some more ideas from Debian: user filter (~/.lessfilter), more zip extensions, and rock/joliet iso handling
Package-Manager: portage-2.2_pre5
Diffstat (limited to 'sys-apps/less')
-rw-r--r-- | sys-apps/less/Manifest | 10 | ||||
-rw-r--r-- | sys-apps/less/files/lesspipe.sh | 56 |
2 files changed, 46 insertions, 20 deletions
diff --git a/sys-apps/less/Manifest b/sys-apps/less/Manifest index 1314f32c8cab..dab57b8c5c3a 100644 --- a/sys-apps/less/Manifest +++ b/sys-apps/less/Manifest @@ -4,18 +4,16 @@ Hash: SHA1 AUX README.Gentoo 823 RMD160 be59c37906fca17fa25f6781d3f5e7abc114dc57 SHA1 5a1f126af728f5220b97623050e2f9b1ea5ae58e SHA256 3985fd1810f660ea1c1f2732f719b069b6934d62d8d9e8a09287e63f049ba27d AUX code2color.patch 1110 RMD160 712f7b79c94f92ee62825d5f53627f18fae693d2 SHA1 a82f937f3a923b52adc4f14cfc9b641903884839 SHA256 a3887126826ef0b4b821bd97cf4e7abfc8b1c9280bf2bb18a2a4cec9a2973936 AUX less.envd 50 RMD160 e9d7b2497aa81e13b740dc765c0fc87d4f1f2f8e SHA1 f903d459e7f0b2c14009304bebb7a045a7cccf9d SHA256 1f186ac4f500c842a9016702b3d7e9d69fe161db23cf56c316ed7f5a51da6a4e -AUX lesspipe.sh 5959 RMD160 e7031f061a9077b18445c050843aa812fde7b6da SHA1 9cec824c7d6404a7ce8bd361b2ed77e2a7e128b3 SHA256 1575928df512965ac4c7befb902b2ed07d548e96bd1d6346b77a0788524bc1bb +AUX lesspipe.sh 6764 RMD160 0e8edac85152aa14a9309ff1ab20a579e443c43a SHA1 1bb8c27c13f2fad9ad057a469cfa6c596c8475d6 SHA256 46dcbaa2546e328357a22ba55ac0fdd2746af3ffb22783f50ed3dc62a5e8b941 DIST code2color 199875 RMD160 378d340a20c3fe500f19116220d54816fe279225 SHA1 b30526dd52c747b8bd6dcf53cf5cc94824c47feb SHA256 ce63f148293a81b0fe5e072f33285f9bf4f1d832f64b23a2220519674a47091d -DIST less-416.tar.gz 294541 RMD160 0f605bd4105aa94f62eddd0316f88c5d6a15bac6 SHA1 8f22bfb8eab70e21c7918ed0a5e61b9833c7d19e SHA256 9b46579741b089e4b148a6e19f7bfdc26afd02ccbf85105fc8314e8c3fb355db DIST less-418.tar.gz 299213 RMD160 a10402aa423e3d3c4d950735208991d7d4afb85d SHA1 ec4fb48680878a7ac3499c46564c47c448b0aa22 SHA256 f532fcd61b012379d3258196a8588fd9d51ecdfb5c795485ab2f78d439b103b4 -EBUILD less-416.ebuild 1181 RMD160 d29dfd27a8ca419aaac40ffcd77d541649a34c73 SHA1 85fa87613bce4a5fc1ea39a43675bc70d2485d6f SHA256 d32849efe274768dcea640f9bbe198c17786f173700cab2b1f1812fa37ac9ce0 EBUILD less-418.ebuild 1180 RMD160 b5a7d6f84bdcc8a0453474a43026b2d4701ba0da SHA1 cd68135063018687e6f010c7a0a912e8b5dd8c62 SHA256 c90c40fe5c1b70d89fedae619c077f3e315b8e5fa4d772092d72bf09c8ffd026 MISC ChangeLog 11303 RMD160 53326547020d882c9d030f5bd1dd875ef25ead17 SHA1 13e3f899581d02b0e859690e93c8491b53dd07b0 SHA256 8d691a226297c7fb907c64c78738d47e928bafe5a913cb9d57f5335f0217839d MISC metadata.xml 164 RMD160 f43cbec30b7074319087c9acffdb9354b17b0db3 SHA1 9c213f5803676c56439df3716be07d6692588856 SHA256 f5f2891f2a4791cd31350bb2bb572131ad7235cd0eeb124c9912c187ac10ce92 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) -iD8DBQFH45qjNQqtfCuFneMRAsRjAJ9PWatG2NSFC29QGveUzDRH5g6kGACcCNm2 -BFCP3orPUFBBFjXE6ZVKOvc= -=zUYD +iD8DBQFIBjh4j9hvisErhMIRAteMAKCrRJr44hNJa+U+wSDno8vYW5r+sACfcmw1 +f8cYALPacE0ohfJc/igoKno= +=wtck -----END PGP SIGNATURE----- diff --git a/sys-apps/less/files/lesspipe.sh b/sys-apps/less/files/lesspipe.sh index c399c50b4113..42fe1a76cab4 100644 --- a/sys-apps/less/files/lesspipe.sh +++ b/sys-apps/less/files/lesspipe.sh @@ -44,6 +44,11 @@ lesspipe() { local DECOMPRESSOR=$(guesscompress "$match") + # User filters + if [[ -x ~/.lessfilter ]] ; then + ~/.lessfilter "$1" && exit 0 + fi + case "$match" in ### Doc files ### @@ -97,7 +102,6 @@ lesspipe() { *.bz2) bzip2 -dc -- "$1" ;; *.gz|*.z) gzip -dc -- "$1" ;; *.lzma) lzma -dc -- "$1" ;; - *.zip) unzip -l "$1" ;; *.rpm) rpm -qpivl --changelog -- "$1" ;; *.cpi|*.cpio) cpio -itv < "$1" ;; *.ace) unace l "$1" ;; @@ -105,8 +109,8 @@ lesspipe() { *.arj) unarj l -- "$1" ;; *.cab) cabextract -l -- "$1" ;; *.lha|*.lzh) lha v "$1" ;; - *.zoo) zoo -list "$1" ;; - *.7z) 7z l -- "$1" ;; + *.zoo) zoo -list "$1" || unzoo -l "$1" ;; + *.7z) 7z l -- "$1" || 7za l -- "$1" ;; *.a) ar tv "$1" ;; *.elf) readelf -a -- "$1" ;; *.so) readelf -h -d -s -- "$1" ;; @@ -114,8 +118,12 @@ lesspipe() { *.rar|.r[0-9][0-9]) unrar l -- "$1" ;; + *.jar|*.war|*.ear|*.xpi|*.zip) + unzip -v "$1" || miniunzip -l "$1" || miniunz -l "$1" || zipinfo -v "$1" + ;; + *.deb|*.udeb) - if type -p dpkg > /dev/null ; then + if type -P dpkg > /dev/null ; then dpkg --info "$1" dpkg --contents "$1" else @@ -134,9 +142,22 @@ lesspipe() { *.mp3) mp3info "$1" || id3info "$1" ;; *.ogg) ogginfo "$1" ;; *.flac) metaflac --list "$1" ;; - *.iso) isoinfo -d -i "$1" ; isoinfo -l -i "$1" ;; - *.bin|*.cue) cd-info --no-header --no-device-info "$1" ;; *.torrent) torrentinfo-console "$1" ;; + *.bin|*.cue|*.raw) + # not all .bin/.raw files are cd images, so fall back to hexdump + cd-info --no-header --no-device-info "$1" || lesspipe_file "$1" + ;; + *.iso) + iso_info=$(isoinfo -d -i "$1") + echo "${iso_info}" + # Joliet output overrides Rock Ridge, so prefer the better Rock + case ${iso_info} in + *$'\n'"Rock Ridge"*) iso_opts="-R";; + *$'\n'"Joliet"*) iso_opts="-J";; + *) iso_opts="";; + esac + isoinfo -l ${iso_opts} -i "$1" + ;; ### Source code ### *.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\ @@ -201,28 +222,35 @@ lesspipe() { if [[ -z $1 ]] ; then echo "Usage: lesspipe.sh <file>" -elif [[ $1 == "-V" ]] ; then +elif [[ $1 == "-V" || $1 == "--version" ]] ; then Id="cvsid" - cvsid="$Id: lesspipe.sh,v 1.27 2008/03/16 13:01:51 vapier Exp $" + cvsid="$Id: lesspipe.sh,v 1.28 2008/04/16 17:33:38 vapier Exp $" cat <<-EOF $cvsid - Copyright 2001-2006 Gentoo Foundation + Copyright 2001-2008 Gentoo Foundation Mike Frysinger <vapier@gentoo.org> (with plenty of ideas stolen from other projects/distros) - - + + EOF less -V elif [[ $1 == "-h" || $1 == "--help" ]] ; then cat <<-EOF lesspipe.sh: preproccess files before sending them to less - + Usage: lesspipe.sh <file> - + lesspipe.sh specific settings: LESSCOLOR env - toggle colorizing of output LESSCOLORIZER env - program used to colorize output (default: code2color) - + + You can create per-user filters as well by creating the executable file: + ~/.lessfilter + One argument is passed to it: the file to display. + + To use lesspipe.sh, simply add to your environment: + export LESSOPEN="|lesspipe.sh %s" + Run 'less --help' or 'man less' for more info EOF elif [[ -d $1 ]] ; then |