From 3da6305b9b1a0deeacc12215eaebc682f44b7aea Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 18 Nov 2014 23:51:52 -0500 Subject: [PATCH] Implement new lesspipe --- bin/lesspipe | 19 +++++++++++++++++++ zprofile | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 bin/lesspipe diff --git a/bin/lesspipe b/bin/lesspipe new file mode 100755 index 00000000..d046bc3a --- /dev/null +++ b/bin/lesspipe @@ -0,0 +1,19 @@ +#!/bin/sh + +case "$1" in + *.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|*.ebuild|*.eclass) + pygmentize -f 256 "$1";; + .bashrc|.bash_aliases|.bash_environment) + pygmentize -f 256 -l sh "$1" + ;; + *) + grep "#\!/bin/bash" "$1" > /dev/null + if [ "$?" -eq "0" ]; then + pygmentize -f 256 -l sh "$1" + else + exit 1 + fi +esac diff --git a/zprofile b/zprofile index 86554df3..18a8b704 100644 --- a/zprofile +++ b/zprofile @@ -39,8 +39,8 @@ fpath=( export LESS='-X -F -g -i -M -R -S -w -z-4' # Set the Less input preprocessor. -if (( $+commands[lesspipe.sh] )); then - export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-' +if (( $+commands[lesspipe] )); then + export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-' fi # Temporary Files