From 852744b01d96aa6ec0457fdd4883b22a0071038d Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Tue, 5 Sep 2023 11:11:40 +0530 Subject: [PATCH] [scripts] ,preview: show zlib compressed files --- scripts/.local/bin/utils/,preview | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/.local/bin/utils/,preview b/scripts/.local/bin/utils/,preview index 7d8296fd..a78a455f 100755 --- a/scripts/.local/bin/utils/,preview +++ b/scripts/.local/bin/utils/,preview @@ -1,6 +1,7 @@ #!/bin/sh -[ "$1" = "with-clear" ] && shift; ,icat-clear # use to be && instead of ; +[ "$1" = "with-clear" ] && shift +,icat-clear # use to be && instead of ; imagepreview() { if [ -n "$KITTY_WINDOW_ID" ]; then timeout 4 kitty +kitten icat --place 60x"$2"@65x2 --transfer-mode file --silent "$1" @@ -23,10 +24,10 @@ audiopreview() { pdfpreview() { if [ -n "$KITTY_WINDOW_ID" ]; then - pdftoppm -png -f 1 -l 1 -jpeg -tiffcompression jpeg "$1" > "/tmp/pdfpreview.jpg" + pdftoppm -png -f 1 -l 1 -jpeg -tiffcompression jpeg "$1" >"/tmp/pdfpreview.jpg" imagepreview "/tmp/pdfpreview.jpg" "$2" else - if ! pdftotext "$1" - ;then + if ! pdftotext "$1" -; then pdftohtml "$1" -i -f 1 -l 3 -stdout >/tmp/pdfpage.html w3m /tmp/pdfpage.html -dump rm /tmp/pdfpage.html @@ -37,13 +38,12 @@ pdfpreview() { everythingelse() { if [ -d "$1" ]; then tree -L 1 -a "$1" - elif file --mime "$1" | grep 'charset=binary'; then - MIMETYPE="$(file --mime ade.sketch | cut -d' ' -f2)" - if echo "$MIMETYPE" | grep 'application/zip'; then - unzip -l "$1" - else - file -b "$1" - fi + elif file --mime "$1" | grep 'charset=binary'; then # no -q in grep to print the line + MIMETYPE="$(file --mime "$1" | cut -d' ' -f2 | cut -d';' -f1)" + case "$MIMETYPE" in + application/zip) echo "unzip" ; unzip -l "$1" ;; + application/zlib) zlib-flate -uncompress <"$1" ;; # FIXME prints "binary" if it has non char data + esac else jq <"$1" 2>/dev/null || cat "$1" || file "$1" fi