dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 24d2f4b51cc44c1ba68c0e070ab0cac882b67e0f
parent 7881b71ce8c12d14d71108b4d9c3d6556a9371d6
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Fri,  9 Oct 2020 12:36:57 +0200

imgpreview & lf configuration for previews

Seems to work well now, using chafa.


Former-commit-id: 8943a7f301564222da33a4dc6b5c66d607c1f3ad
Diffstat:
Mlf/lfrc | 2+-
Alf/preview | 46++++++++++++++++++++++++++++++++++++++++++++++
Dlf/preview.sh | 2--
Ascripts/imgpreview | 19+++++++++++++++++++
4 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/lf/lfrc b/lf/lfrc @@ -23,7 +23,7 @@ set ifs "\n" set scrolloff 10 set color256 on -set previewer ~/.config/lf/preview.sh +set previewer ~/.config/lf/preview # }}} # Command definitions {{{ diff --git a/lf/preview b/lf/preview @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +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) + pdftoppm -png -f 1 -singlefile "$1" "$CACHE" + imgpreview "$CACHE.png" + rm "$CACHE" + ;; + # *.epub) + # CACHE=$(mktemp) + # epub-thumbnailer "$1" "$CACHE" 1024 + # imgpreview "$CACHE" + # rm "$CACHE" + # ;; + *.bmp|*.jpg|*.jpeg|*.png|*.xpm) + imgpreview "$1" + ;; + *.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) + ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0 + imgpreview "$CACHE" + rm "$CACHE" + ;; + *) + bat --color=always --theme=base16 "$1" + ;; +esac + diff --git a/lf/preview.sh b/lf/preview.sh @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -bat --color=always --theme=base16 "$1" diff --git a/scripts/imgpreview b/scripts/imgpreview @@ -0,0 +1,19 @@ +#!/bin/sh +WIDTH="$2" +[ -z "$2" ] && WIDTH="$(tput cols)" +os=$(uname -s | tr '[:upper:]' '[:lower:]') +case "$os" in + linux*) + printf "Haven't chosen a previewer for Linux yet.\n" + ;; + darwin*) + command -v chafa 1>/dev/null 2>&1 || { printf "Please install chafa\n" && exit 1; } + chafa -c 256 -s 80x"$WIDTH" "$1" + ;; + msys*|cygwin*|mingw*|nt|win*) + printf "Windows not supported.\n" + ;; + *) + printf "Operating system %s is unknown.\n" "$os" + ;; +esac