]> Sergey Matveev's repositories - nnn.git/commitdiff
preview-tui: directory preview/iconlookup (#954)
authorluukvbaal <31730729+luukvbaal@users.noreply.github.com>
Wed, 21 Apr 2021 12:44:38 +0000 (05:44 -0700)
committerGitHub <noreply@github.com>
Wed, 21 Apr 2021 12:44:38 +0000 (18:14 +0530)
* preview-tui: directory preview/iconlookup

* preview-tui-ext: NNN_ARCHIVE note

plugins/.iconlookup
plugins/preview-tui
plugins/preview-tui-ext

index e43c1ad47e2bda2917d81b3e536abebb405dc974..7093986360f49168be9559b576e6d969c6d9b56f 100755 (executable)
@@ -165,9 +165,9 @@ awk 'BEGIN {
 
 # i
     icons["ico"][1] = icons["picturefile"][1]; icons["ico"][2] = icons["picturefile"][2]
-    icons["img"][1] = icons["opticaldisc"][1]; icons["img"][2] = icons["opticaldisc"][2]
+    icons["img"][1] = icons["opticaldisk"][1]; icons["img"][2] = icons["opticaldisk"][2]
     icons["ini"][1] = icons["configure"][1]; icons["ini"][2] = icons["configure"][2]
-    icons["iso"][1] = icons["opticaldisc"][1]; icons["iso"][2] = icons["opticaldisc"][2]
+    icons["iso"][1] = icons["opticaldisk"][1]; icons["iso"][2] = icons["opticaldisk"][2]
 
 # j
     icons["jar"][1] = icons["java"][1]; icons["jar"][2] = icons["java"][2]
@@ -272,7 +272,7 @@ awk 'BEGIN {
 
 # x
     icons["xbps"][1] = icons["archive"][1]; icons["xbps"][2] = color_archive
-    icons["xcf"][1] = icons["imagefile"][1]; icons["xcf"][2] = color_image
+    icons["xcf"][1] = icons["picturefile"][1]; icons["xcf"][2] = color_image
     icons["xhtml"][1] = icons["htm"][1]; icons["xhtml"][2] = icons["htm"][2]
     icons["xls"][1] = ""; icons["xls"][2] = color_default
     icons["xlsx"][1] = ""; icons["xlsx"][2] = color_default
index 6069356d2b22eac8cd31ee78539d885b33a6e621..ffabe15588a8ccbf6d705d989a23459553b67c37 100755 (executable)
@@ -150,9 +150,9 @@ preview_file () {
     if [ -d "$1" ]; then
         cd "$1" || return
         if exists tree; then
-            fifo_pager tree -L 1 --dirsfirst -F -C
+            fifo_pager tree -L 3 --dirsfirst -C -F --noreport -i
         elif exists exa; then
-            fifo_pager exa -G --colour=always 2>/dev/null
+            exa -G --colour=always 2>/dev/null
         else
             fifo_pager ls --color=always
         fi
index a1f64b22d8d84831ec84ba5916547274bb6c71a3..72bda70d1fe8b9c92a8aca0963b59d4e06e19b5f 100755 (executable)
@@ -16,7 +16,8 @@
 #    - unzip
 #    - tar
 #    - man
-#    - optional: bsdtar or atool for additional archive preview
+#    - optional: bsdtar or atool for additional archive preview (make sure to export NNN_ARCHIVE
+#                as suggested in the wiki: https://github.com/jarun/nnn/wiki/Usage#configuration)
 #    - optional: bat for code syntax highlighting
 #    - optional: ueberzug, kitty terminal, viu or catimg for images
 #    - optional: convert(ImageMagick) for playing gif preview
@@ -167,17 +168,16 @@ preview_file() {
     # Otherwise, falling back to the defaults.
     if [ -d "$1" ]; then
         cd "$1" || return
-        if exists tree; then
-            if [ "$ICONLOOKUP" -ne 0 ] && [ -f "$(dirname "$0")"/.iconlookup ]; then
-                [ "$SPLIT" = h ] && BSTR="\n"
-                tree -L 1 --dirsfirst -F --noreport -i | head -n "$((lines - 3))" | "$(dirname "$0")"/.iconlookup -l "$cols" -B "$BSTR" -b " "
-            else
-                fifo_pager tree -L 1 --dirsfirst -C -F --noreport -i
-            fi;
+        if [ "$ICONLOOKUP" -ne 0 ] && [ -f "$(dirname "$0")"/.iconlookup ]; then
+            [ "$SPLIT" = h ] && BSTR="\n"
+            # shellcheck disable=SC2012
+            ls -F --group-directories-first | head -n "$((lines - 3))" | "$(dirname "$0")"/.iconlookup -l "$cols" -B "$BSTR" -b " "
+        elif exists tree; then
+            fifo_pager tree -L 3 --dirsfirst -C -F --noreport -i
         elif exists exa; then
-            fifo_pager exa -G --colour=always 2>/dev/null
+            exa -G --group-directories-first --colour=always 2>/dev/null
         else
-            fifo_pager ls --color=always
+            fifo_pager ls --group-directories-first --color=always
         fi
     elif [ "${encoding#*)}" = "binary" ]; then
         if [ "${mimetype%%/*}" = "image" ]; then