diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-11-22 22:29:08 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-11-22 22:29:08 +0000 |
commit | 46f95a66d38420598690d7c55f986698e4f5252d (patch) | |
tree | 1d9b74bd85632168bcdd4f908a1d025c4e315c56 /sys-apps/less | |
parent | Version bump #113276 by Christoph Gysin. (diff) | |
download | historical-46f95a66d38420598690d7c55f986698e4f5252d.tar.gz historical-46f95a66d38420598690d7c55f986698e4f5252d.tar.bz2 historical-46f95a66d38420598690d7c55f986698e4f5252d.zip |
add support for .Z compressed files, colorize more source files, add support for -h/-v, and allow people to control the control stuff more #113240 by Yuri Karaban
Package-Manager: portage-2.0.53_rc7
Diffstat (limited to 'sys-apps/less')
-rw-r--r-- | sys-apps/less/Manifest | 8 | ||||
-rw-r--r-- | sys-apps/less/files/lesspipe.sh | 49 |
2 files changed, 48 insertions, 9 deletions
diff --git a/sys-apps/less/Manifest b/sys-apps/less/Manifest index d627f5ad5800..625476af480d 100644 --- a/sys-apps/less/Manifest +++ b/sys-apps/less/Manifest @@ -6,7 +6,7 @@ MD5 0f015b2ac33a3d039f77c6f15b768895 files/code2color.patch 221 MD5 6f05cb473c8bd03fb8fb5ba7466aa804 files/digest-less-382-r2 60 MD5 c9bb99cd4f916916f975c59d38c3d590 files/digest-less-385 60 MD5 f5d6d65946fd9d3091b3d06bc3615492 files/digest-less-385_p4-r2 181 -MD5 e7d23b3be643f69db9fe6a0c6162dbda files/lesspipe.sh 4129 +MD5 2f19ad1ee4ecc66106a9d236c6642943 files/lesspipe.sh 5368 MD5 adb0b1124c355f33197454d2be87bfd3 less-382-r2.ebuild 791 MD5 147e4c10285042fad83d0c3592498e8c less-385.ebuild 800 MD5 4011fc14d9d06c6e8500ddc95e26ecd2 less-385_p4-r2.ebuild 1528 @@ -14,7 +14,7 @@ MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) -iD8DBQFDcA2ogIKl8Uu19MoRAgH7AJ4qf+BRRNevpBGwAFOwT+Ok+S/wyQCeI3MH -aLqcNTlxNgXh7HOE/I9TcUY= -=vmoU +iD8DBQFDg5xGgIKl8Uu19MoRAprRAJ0frxYFUxi+HNYoYHuaziqaO0LWCACfW4kP +cJmNI6xtLGhRWhp6RR4Noho= +=HGXK -----END PGP SIGNATURE----- diff --git a/sys-apps/less/files/lesspipe.sh b/sys-apps/less/files/lesspipe.sh index a34827c5f5e7..43d3c6bfdf18 100644 --- a/sys-apps/less/files/lesspipe.sh +++ b/sys-apps/less/files/lesspipe.sh @@ -1,5 +1,5 @@ #!/bin/bash -# +# # Preprocessor for 'less'. Used when this environment variable is set: # LESSOPEN="|lesspipe.sh %s" @@ -11,6 +11,7 @@ guesscompress() { case "$1" in *.gz) echo "gunzip -c" ;; *.bz2) echo "bunzip2 -c" ;; + *.Z) echo "compress -d" ;; *) echo "cat" ;; esac } @@ -125,13 +126,27 @@ lesspipe() { *.bin|*.cue) cd-info --no-header --no-device-info "$1" ;; ### Source code ### - *.awk|*.java|*.js|*.m4|*.pl|*.sh|\ - *.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|*.[sS]|\ - *.patch) + *.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\ + *.ad[asb]|*.asm|*.inc|*.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|\ + *.lsp|*.l|*.pas|*.p|*.xml|*.xps|*.xsl|*.axp|*.ppd|*.pov|\ + *.diff|*.patch|*.py|*.rb|*.sql) + + # Allow people to flip color off if they dont want it + case ${LESSCOLOR} in + [yY][eE][sS]|1|true) LESSCOLOR=1;; + [nN][oO]|0|false) LESSCOLOR=0;; + *) LESSCOLOR=1;; # default to colorize + esac + [[ ${LESSCOLORIZER+set} != "set" ]] && LESSCOLORIZER=code2color + if [[ ${LESSCOLOR} == "0" ]] || [[ -z ${LESSCOLORIZER} ]] ; then + # let less itself handle these files + exit 0 + fi + # Only colorize if we know less will handle raw codes for opt in ${LESS} ; do if [[ ${opt} == "-r" || ${opt} == "-R" ]] ; then - code2color "$1" + ${LESSCOLORIZER} "$1" break fi done @@ -167,6 +182,30 @@ lesspipe() { if [[ -z $1 ]] ; then echo "Usage: lesspipe.sh <file>" +elif [[ $1 == "-V" ]] ; then + Id="lesspipe.sh" + cvsid="$Id: lesspipe.sh,v 1.12 2005/11/22 22:29:08 vapier Exp $" + cat <<-EOF + $cvsid + Copyright 2001-2005 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) + + Run 'less --help' or 'man less' for more info + EOF elif [[ -d $1 ]] ; then ls -alF -- "$1" else |