aboutsummaryrefslogtreecommitdiff
path: root/files/.config/nnn/plugins/mimelist
diff options
context:
space:
mode:
Diffstat (limited to 'files/.config/nnn/plugins/mimelist')
-rwxr-xr-xfiles/.config/nnn/plugins/mimelist12
1 files changed, 10 insertions, 2 deletions
diff --git a/files/.config/nnn/plugins/mimelist b/files/.config/nnn/plugins/mimelist
index ccfe05a..3813c09 100755
--- a/files/.config/nnn/plugins/mimelist
+++ b/files/.config/nnn/plugins/mimelist
@@ -2,8 +2,12 @@
# Description: Find and list files by mime type in smart context
#
+# Dependencies:
+# - file
+# - mimetype (optional, PERL File MimeInfo)
+#
# Shell: POSIX compliant
-# Author: Arun Prakash Jana
+# Author: Arun Prakash Jana, Michel DHOOGE
# shellcheck disable=SC1090,SC1091
. "$(dirname "$0")"/.nnn-plugin-helper
@@ -12,4 +16,8 @@ printf "mime (e.g., video/audio/image): "
read -r mime
printf "%s" "+l" > "$NNN_PIPE"
-find . | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"
+if type mimetype >/dev/null 2>&1; then
+ find . | mimetype -f - | grep "$mime" | awk -F: '{printf "%s%c", $1, 0}' > "$NNN_PIPE"
+else
+ find . | file -if- | grep "$mime" | awk -F: '{printf "%s%c", $1, 0}' > "$NNN_PIPE"
+fi