1
0
Fork 0

lf: prevent double preview of yaml/json

This commit is contained in:
Luca Bilke 2024-07-31 11:20:35 +02:00
parent f69b9957c9
commit 50469288e9
Signed by: luca
GPG Key ID: F6E11C9BAA7C82F5
1 changed files with 16 additions and 22 deletions

View File

@ -23,11 +23,9 @@ video() {
}
text() {
for cmd in bat batcat head; do
for cmd in bat batcat; do
command -v $cmd >/dev/null 2>&1 && break
done
case $cmd in
bat*)
$cmd \
--color=always \
--italic-text=always \
@ -36,12 +34,8 @@ text() {
--tabs=4 \
--theme=base16 \
--line-range=":$h" \
--terminal-width="$((w - 2))" "$@" "$f"
;;
head)
head -n "$h" "$f"
;;
esac
--terminal-width="$((w - 2))" \
"$@"
}
run() {
@ -67,8 +61,8 @@ mimetest() {
*/vnd.sun.xml.writer) run odt2txt "$f" ;;
*/msword) run catdoc "$f" ;;
*/vnd.openxmlformats-officedocument.wordprocessingml.document) run docx2txt <"$f" ;;
*/vnd.ms-excel) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv ;;
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv ;;
*/vnd.ms-excel) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv "$f" ;;
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv "$f" ;;
*/pgp-encrypted) run gpg -d -- "$f" ;;
*/pkix-cert) run openssl x509 -text -noout -in "$f" ;;
*opendocument*) run odt2txt "$f" ;;
@ -84,9 +78,9 @@ mimetest() {
*/*yaml)
# [ ! -f "${CACHE}.txt" ] && run yq -C <"$f" >"${CACHE}.txt"
# text "${CACHE}.txt"
text --language=yaml
text --language=yaml "$f"
;;
*/*lua) text ;;
*/*lua) text "$f" ;;
*/epub+zip)
[ ! -f "$CACHE" ] && run epub-thumbnailer "$f" "$CACHE" 1024
image "$CACHE"
@ -101,7 +95,7 @@ mimetest() {
;;
video/*) video ;;
image/*) image ;;
*text*) text ;;
*text*) text "$f" ;;
*) return 1 ;;
esac
}