mimelist (617B)
1 #!/usr/bin/env sh 2 3 # Description: Find and list files by mime type in smart context 4 # 5 # Dependencies: 6 # - file 7 # - mimetype (optional, PERL File MimeInfo) 8 # 9 # Shell: POSIX compliant 10 # Author: Arun Prakash Jana, Michel DHOOGE 11 12 # shellcheck disable=SC1090,SC1091 13 . "$(dirname "$0")"/.nnn-plugin-helper 14 15 printf "mime (e.g., video/audio/image): " 16 read -r mime 17 18 printf "%s" "+l" > "$NNN_PIPE" 19 if type mimetype >/dev/null 2>&1; then 20 find . | mimetype -f - | grep "$mime" | awk -F: '{printf "%s%c", $1, 0}' > "$NNN_PIPE" 21 else 22 find . | file -if- | grep "$mime" | awk -F: '{printf "%s%c", $1, 0}' > "$NNN_PIPE" 23 fi