aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mimelist
blob: f179e6e38f3db68845220525a0691828fd8e9af7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env sh

# Description: Run fd/find in subtree and list files by mime type in smart 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" "+l" > "$NNN_PIPE"
$fd | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"