aboutsummaryrefslogtreecommitdiff
path: root/.config/lf/preview
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-08 16:41:50 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-08 16:41:50 +0530
commit6e9091e26593a145e6350a01bad53f26acea75a1 (patch)
tree2d841fa503d20560d2f6e57a33c8ded65d817be8 /.config/lf/preview
parentf94c1202afce479d61ff833d8cd05fe417c98288 (diff)
pushing all the dotfiles again
Diffstat (limited to '.config/lf/preview')
-rwxr-xr-x.config/lf/preview48
1 files changed, 48 insertions, 0 deletions
diff --git a/.config/lf/preview b/.config/lf/preview
new file mode 100755
index 0000000..3069a06
--- /dev/null
+++ b/.config/lf/preview
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# Clear the last preview (if any)
+$HOME/.config/lf/image clear
+
+# Calculate where the image should be placed on the screen.
+num=$(printf "%0.f\n" "`echo "$(tput cols) / 2" | bc`")
+numb=$(printf "%0.f\n" "`echo "$(tput cols) - $num - 1" | bc`")
+numc=$(printf "%0.f\n" "`echo "$(tput lines) - 2" | bc`")
+
+case "$1" in
+ *.tgz|*.tar.gz) tar tzf "$1";;
+ *.tar.bz2|*.tbz2) tar tjf "$1";;
+ *.tar.txz|*.txz) xz --list "$1";;
+ *.tar) tar tf "$1";;
+ *.zip|*.jar|*.war|*.ear|*.oxt) unzip -l "$1";;
+ *.rar) unrar l "$1";;
+ *.7z) 7z l "$1";;
+ *.[1-8]) man "$1" | col -b ;;
+ *.o) nm "$1" | less ;;
+ *.torrent) transmission-show "$1";;
+ *.iso) iso-info --no-header -l "$1";;
+ *odt,*.ods,*.odp,*.sxw) odt2txt "$1";;
+ *.doc) catdoc "$1" ;;
+ *.docx) docx2txt "$1" - ;;
+ *.csv) cat "$1" | sed s/,/\\n/g ;;
+ *.pdf)
+ CACHE=$(mktemp /tmp/thumbcache.XXXXX)
+ pdftoppm -png -f 1 -singlefile "$1" "$CACHE"
+ $HOME/.config/lf/image draw "$CACHE.png" $num 1 $numb $numc
+ ;;
+ *.epub)
+ CACHE=$(mktemp /tmp/thumbcache.XXXXX)
+ epub-thumbnailer "$1" "$CACHE" 1024
+ $HOME/.config/lf/image draw "$CACHE" $num 1 $numb $numc
+ ;;
+ *.bmp|*.jpg|*.jpeg|*.png|*.xpm)
+ $HOME/.config/lf/image draw "$1" $num 1 $numb $numc
+ ;;
+ *.wav|*.mp3|*.flac|*.m4a|*.wma|*.ape|*.ac3|*.og[agx]|*.spx|*.opus|*.as[fx]|*.flac) exiftool "$1";;
+ *.avi|*.mp4|*.wmv|*.dat|*.3gp|*.ogv|*.mkv|*.mpg|*.mpeg|*.vob|*.fl[icv]|*.m2v|*.mov|*.webm|*.ts|*.mts|*.m4v|*.r[am]|*.qt|*.divx)
+ CACHE=$(mktemp /tmp/thumbcache.XXXXX)
+ ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0
+ $HOME/.config/lf/image draw "$CACHE" $num 1 $numb $numc
+ ;;
+ *) highlight --out-format ansi "$1" || cat "$1";;
+esac
+