1#!/bin/sh
2
3# Plugin to list files in CWD by a given mime type
4# Written by L. Abramovich
5
6mime=""
7
8if [ -n "$1" ] && { [ "$1" = "--help" ] || [ "$1" = "help" ]; }; then
9	name="$(basename "$0")"
10	printf "List files in CWD by mime type\n"
11	printf "Usage: %s\n" "$name"
12	exit 0
13fi
14
15while [ -z "$mime" ]; do
16	printf "Mime type: "
17	read -r mime
18done
19
20find . -maxdepth 1 -mindepth 1 | file -F'@' -N -n --mime-type -if- | grep "@\ .*${mime}" | cut -d"@" -f1 | cut -d"/" -f2-10 | sort
21
22exit 0
23