aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mimelist
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-03 14:55:33 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-03 14:55:33 +0530
commiteee5057da5d5063f5a5c3e0059e98ad8f6ba179e (patch)
tree0351585ca189e49dbe7938d9636b63cb75479a5d /plugins/mimelist
parente8e87f6ba2b72a8b7c2eb9a63d8a37a71f148882 (diff)
downloadnnn-eee5057da5d5063f5a5c3e0059e98ad8f6ba179e.tar.gz
Plugin mimelist: support reading file list from (cmd as) plugin
Diffstat (limited to 'plugins/mimelist')
-rwxr-xr-xplugins/mimelist21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/mimelist b/plugins/mimelist
new file mode 100755
index 0000000..0ec7c0f
--- /dev/null
+++ b/plugins/mimelist
@@ -0,0 +1,21 @@
+#!/usr/bin/env sh
+
+# Description: Run fd/find in subtree and list files by mime type in current context
+# Requires: fd/find
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash jana
+
+. "$(dirname "$0")"/.nnn-plugin-helper
+
+if [ "$(cmd_exists fd)" -eq "0" ]; then
+ fd=fd
+else
+ fd=find
+fi
+
+printf "mime: "
+read -r mime
+
+printf "%s" "0l" > "$NNN_PIPE"
+$fd | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"