21 lines
605 B
Bash
Executable File
21 lines
605 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 --validate-input \
|
|
--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}"
|