From 0fbf0aff4cfacdb3a51b89ea2a6877ccfa33da73 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 25 Sep 2024 19:36:32 +0100 Subject: [PATCH] [file_previewer.sh]: Add symlink handling --- file_previewer.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/file_previewer.sh b/file_previewer.sh index 9ea1c7b..5cbe9e7 100755 --- a/file_previewer.sh +++ b/file_previewer.sh @@ -9,7 +9,14 @@ height="${3:-$(tput lines)}" x=$4 y=$5 -case "$(mimetype --brief -- "$file")" in +mimetype="$(mimetype --brief -- "$file")" + +if [ "$mimetype" = "inode/symlink" ]; then + file="$(readlink "$file")" + mimetype="$(mimetype --brief -- "$file")" +fi + +case "$mimetype" in application/gzip | application/msword | application/x-iso9660-image | application/vnd.openxmlformats-officedocument.wordprocessingml.document | application/vnd.openxmlformats-officedocument.presentationml.presentation | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) exiftool "$file" | bat --theme='base16' --terminal-width "$(($width-4))" --force-colorization;;