Currently, lesspipe.sh has a hardcoded list of file types which are displayed via external programs, and the user's only options are to disable lesspipe.sh, roll their own, or use -L selectively in order to avoid the default behavior (the example from the forums is viewing HTML source rather than rendering HTML via links/lynx). This patch allows users to define LESSIGNORE, a colon-delimited list of extensions which should not be rendered. It's an added two-lines which doesn't touch any of the existing behavior. I will attach a patch. Reproducible: Always
Created attachment 149940 [details, diff] Patch to use $LESSIGNORE This is the patch that I posted in this forum thread: http://forums.gentoo.org/viewtopic-t-688322-highlight-.html
two lines which execute external programs ;). it also doesnt seem to handle multi-dotted things such as ".tar.gz" perhaps this: for ignore in ${LESSIGNORE//:/ } ; do [[ ${match} == *.${ignore} ]] && exit 0 done
another alternative: add a ~/.lessfilter that does: #!/bin/sh echo "$1" | grep '\.html$' && exit 1 exit 0
Haha, thanks for giving me a bash-only version. I'm not as familiar with the various splitting/matching features in bash, so I figured I'd write something that works. Your first suggestion seems the best to me. Do you think it's possible to get that merged?
i'll merge it as soon as you test it and say it works for you
Ok, yeah it seems great. With the environment variable unset, things work as normal. With it set, I am able to turn off highlighting for particular extensions. Interestingly, it doesn't seem to have to be colon-seperated. For instance, the following two invocations seem to work equally well: LESSIGNORE="mp3 html" less foo.mp3 LESSIGNORE="mp3:html" less foo.mp3 Also, compound extensions (e.g. tar.gz or 1.bz2) seem to work. It looks good. Thanks for helping me with this!
thanks for testing ... ive added the code in question (minus the colon filter, so now it's just a space delimited list) http://sources.gentoo.org/sys-apps/less/files/lesspipe.sh?r1=1.28&r2=1.29