Skip to content

Commit

Permalink
improve parsing of LESSCOLORIZER variable and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wofr06 committed Oct 3, 2024
1 parent d75745c commit cd7b8f4
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lesspipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,14 @@ has_colorizer () {
batconfig=$($prog --config-file)
[[ -n $lang ]] && $prog --list-languages|sed 's/.*:/,/;s/$/,/'|grep -i ",$lang," > /dev/null && opt=(-l "$lang")
opt2=${LESSCOLORIZER##*--}
if [[ $opt2 == style=* ]]; then
style=${opt2##*=}
elif [[ $opt2 == theme=* ]]; then
theme=${opt2##*=}
fi
opt2=$(echo ${LESSCOLORIZER%[ ]--*}|sed 's/ $//g')
[[ $opt2 == style=* ]] && style=${opt2##*=}
[[ $opt2 == theme=* ]] && theme=${opt2##*=}
opt2=$(echo "$LESSCOLORIZER"|tr -s ' ')
opt2=${opt2%[ ]--*}
opt2=${opt2##*--}
if [[ $opt2 == style=* ]]; then
style=${opt2##*=}
elif [[ $opt2 == theme=* ]]; then
theme=${opt2##*=}
fi
[[ $opt2 == style=* ]] && style=${opt2##*=}
[[ $opt2 == theme=* ]] && theme=${opt2##*=}
[[ -n $theme ]] && theme=$(echo "${theme##*=}"|tr -d '/"\047\134/')

[[ -z $style ]] && style=$BAT_STYLE
[[ -z $theme ]] && theme=$BAT_THEME
if [[ -r "$batconfig" ]]; then
Expand Down

0 comments on commit cd7b8f4

Please sign in to comment.