diff --git a/lesspipe.sh b/lesspipe.sh index 23e2c9e..a279cff 100755 --- a/lesspipe.sh +++ b/lesspipe.sh @@ -437,23 +437,25 @@ has_colorizer () { [[ -n $3 ]] && lang=$3 || lang=$2 case $prog in bat|batcat) + batconfig=$($prog --config-file) [[ -n $lang ]] && $prog --list-languages|sed 's/.*:/,/;s/$/,/'|grep -i ",$lang," > /dev/null && opt=(-l "$lang") [[ -n $LESSCOLORIZER && $LESSCOLORIZER = *\ *--style=* ]] && style="${LESSCOLORIZER/* --style=/}" [[ -z $style ]] && style=$BAT_STYLE [[ -n $LESSCOLORIZER && $LESSCOLORIZER = *\ *--theme=* ]] && theme="${LESSCOLORIZER/* --theme=/}" [[ -z $theme ]] && theme=$BAT_THEME - if [[ -r "$HOME/.config/bat/config" ]]; then + if [[ -r "$batconfig" ]]; then if [[ -z $style ]]; then - grep -q -e '^--style' "$HOME/.config/bat/config" || style=plain + grep -q -e '^--style' "$batconfig" || style=plain fi if [[ -z $theme ]]; then - grep -q -e '^--theme' "$HOME/.config/bat/config" || theme=ansi + grep -q -e '^--theme' "$batconfig" || theme=ansi fi else [[ -z $style ]] && style=plain [[ -z $theme ]] && theme=ansi fi - opt+=(--style="${style%% *}" --theme="${theme%%[|&;<>]*}") + style="${style%% *}" theme="${theme%%[|&;<>]*}" + opt+=(${style:+--style="$style"} ${theme:+--theme="$theme"}) opt+=("$COLOR" --paging=never "$1") ;; pygmentize) pygmentize -l "$lang" /dev/null &>/dev/null && opt=(-l "$lang") || opt=(-g)