mirror of
https://github.com/jarun/nnn.git
synced 2024-11-25 04:11:29 +00:00
5b05c8b9b1
Only gawk undestands the \0 syntax feat(mimelist): use `mimetype` for better type detection docs(mimelist): add author & dependencies
24 lines
617 B
Bash
Executable file
24 lines
617 B
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# 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
|
|
|
|
# shellcheck disable=SC1090,SC1091
|
|
. "$(dirname "$0")"/.nnn-plugin-helper
|
|
|
|
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
|