Zsh-ify lessfilter
This commit is contained in:
parent
b0cd0f42af
commit
fc206f88b0
10
.lessfilter
10
.lessfilter
|
@ -2,17 +2,21 @@
|
|||
# Try to use highlight. If that fails or the output looks suspicious, use
|
||||
# lesspipe normally.
|
||||
|
||||
command -v highlight > /dev/null || return 1
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
command -v highlight > /dev/null
|
||||
file="${1}"
|
||||
|
||||
local output="$(highlight --force \
|
||||
--out-format=truecolor \
|
||||
--style=base16/unikitty-reversible \
|
||||
--stdout "${file}")"
|
||||
[[ ${?} -eq 0 ]] || return 1
|
||||
ret=${?}
|
||||
[[ ${ret} -eq 0 ]] || return ${ret}
|
||||
|
||||
# Try to catch when the output is just the magic string
|
||||
if [[ ${#output} -lt 256 && $(stat --printf="%s" "${file}") -gt 256 ]]; then
|
||||
zmodload zsh/stat
|
||||
if [[ ${#output} -lt 256 && $(zstat +size "${file}") -gt 256 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user