nnn/plugins/mimelist

24 lines
617 B
Plaintext
Raw Normal View History

#!/usr/bin/env sh
2020-11-22 14:39:14 +00:00
# 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, Michel DHOOGE
2022-07-16 17:47:32 +00:00
# shellcheck disable=SC1090,SC1091
. "$(dirname "$0")"/.nnn-plugin-helper
2020-11-12 02:47:14 +00:00
printf "mime (e.g., video/audio/image): "
read -r mime
printf "%s" "+l" > "$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