From eee5057da5d5063f5a5c3e0059e98ad8f6ba179e Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 3 May 2020 14:55:33 +0530 Subject: Plugin mimelist: support reading file list from (cmd as) plugin --- plugins/mimelist | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 plugins/mimelist (limited to 'plugins/mimelist') 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" -- cgit v1.2.3-70-g09d2