aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_filter_mime.fish
blob: 48fd0b96902b335339e1625cb0adccabaf9c8387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#
# $argv[1] is a mimetype. The mimetype may contain wildcards. All
# following arguments are filenames. Filenames matching the mimetype
# are returned.
#

function __fish_filter_mime -d "Select files with a specific mimetype"

	set -l mime_search $argv[1]
	set -e argv[1]

	set -l mime (mimedb -f $argv)
	set -l res

	for i in (seq (count $mime))
		switch $mime[$i]
			case $mime_search
				set res $res $argv[$i]
		end
	end
	printf "%s\n" $res
end