This commit is contained in:
2026-08-19 22:09:56 +02:00
parent ef1a5d8651
commit 90f5dca59e
5 changed files with 631 additions and 0 deletions

26
lf/preview Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
set -e
set -u
file="$1"
width="${2:-80}"
height="${3:-24}"
case "$(file -Lb --mime-type -- "$file")" in
image/*)
chafa -f sixel -s "${width}x${height}" --animate off --polite on -t 1 --bg black "$file"
;;
text/*)
cat -v "$file"
;;
application/pdf)
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
pdftoppm -png -singlefile -r 144 "$file" "$tmpdir/output"
chafa -f sixel -s "${width}x${height}" "$tmpdir/output.png"
;;
*)
echo "Unsupported file type: $file" >&2
exit 1
;;
esac