dotfiles/.lessfilter
tastytea 77a4a3325e
Remove --validate-input from highlight
It causes some text to be swallowed
2022-04-12 07:33:14 +02:00

20 lines
560 B
Bash
Executable File

#!/bin/zsh
# Try to use highlight. If that fails or the output looks suspicious, use
# lesspipe normally.
command -v highlight > /dev/null || return 1
file="${1}"
local output="$(highlight --force \
--out-format=truecolor \
--style=base16/unikitty-reversible \
--stdout "${file}")"
[[ ${?} -eq 0 ]] || return 1
# Try to catch when the output is just the magic string
if [[ ${#output} -lt 256 && $(stat --printf="%s" "${file}") -gt 256 ]]; then
return 1
fi
print "${output}"