aboutsummaryrefslogtreecommitdiff
path: root/config/lf/previewer.sh
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-12-21 14:17:42 +0530
committerAkshay Nair <phenax5@gmail.com>2020-12-21 14:17:42 +0530
commitebab2f2586739a9e7d0df38f9a1b2eca18b7c719 (patch)
treeca630f596ba2ce011021e5516f237f3527e5db96 /config/lf/previewer.sh
parent810a3e60ca64e18a11b55ec7e1c2d85e56e51bd5 (diff)
downloadnixos-config-ebab2f2586739a9e7d0df38f9a1b2eca18b7c719.tar.gz
nixos-config-ebab2f2586739a9e7d0df38f9a1b2eca18b7c719.zip
Moves ls and dunst configs and enables notifications
Diffstat (limited to '')
-rwxr-xr-xconfig/lf/previewer.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/config/lf/previewer.sh b/config/lf/previewer.sh
new file mode 100755
index 0000000..1b748e1
--- /dev/null
+++ b/config/lf/previewer.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+width=`echo "$(tput cols) / 2" | bc`;
+height=`echo "$(tput lines) - 3" | bc`;
+
+x=$((width - 3));
+y=3;
+
+~/scripts/image.sh clear;
+
+case "$1" in
+ # Archives
+ *.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";;
+ *.o) nm "$1" | less ;;
+ *.apk) mediainfo "$1" ;;
+
+ # Docs
+ *.md|*.org) glow -s dark "$1" ;;
+ *.csv) cat "$1" | sed s/,/\\n/g ;;
+ *.pdf) pdftotext "$1" - ;;
+ *.docx) docx2txt "$1" - ;;
+ *.epub) mediainfo "$1" ;;
+ *.[1-8]) man "$1" | col -b ;;
+
+ # Images
+ *.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp) mediainfo "$1"; ;;
+
+ #*.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp)
+ #~/scripts/image.sh draw "$1" "$x" "$y" "$width" "$height";
+ #;;
+
+ # Audio
+ *.wav|*.mp3|*.flac|*.m4a|*.wma|*.ape|*.ac3|*.og[agx]|*.spx|*.opus|*.as[fx]|*.flac)
+ mediainfo "$1"
+ ;;
+
+ # Video
+ *.avi|*.mp4|*.wmv|*.dat|*.3gp|*.ogv|*.mkv|*.mpg|*.mpeg|*.vob|*.fl[icv]|*.m2v|*.mov|*.webm|*.ts|*.mts|*.m4v|*.r[am]|*.qt|*.divx)
+ mediainfo "$1";
+ ;;
+
+ # Syntax
+ *) highlight --out-format ansi "$1" || cat "$1" ;;
+esac