From 53bd555c6dd0ac87d9814bfb9b6af6feb9bac796 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Sat, 3 May 2014 15:56:36 -0500 Subject: [PATCH] Try `lesspipe` in addition to `lesspipe.sh` for LESSOPEN Debian based systems have `lesspipe`, without '.sh' suffix. Since `$commands` is an associative array, we do index search and set the input preprocessor on first match. --- runcoms/zprofile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runcoms/zprofile b/runcoms/zprofile index a2f7bd5..08d39be 100644 --- a/runcoms/zprofile +++ b/runcoms/zprofile @@ -57,8 +57,9 @@ path=( export LESS='-F -g -i -M -R -S -w -X -z-4' # Set the Less input preprocessor. -if (( $+commands[lesspipe.sh] )); then - export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-' +# Try both `lesspipe` and `lesspipe.sh` as either might exist on a system. +if (( $#commands[(i)lesspipe(|.sh)] )); then + export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-" fi #