-
Notifications
You must be signed in to change notification settings - Fork 0
/
findtype
executable file
·71 lines (63 loc) · 1.69 KB
/
findtype
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env fish
# findtype - Find files of a specified type.
# Generally you can just use finda, findc, findd, etc, instead.
argparse -n "findtype" --ignore-unknown 'h/help' 'd/dotfiles' -- $argv
set type "$argv[1]"
set script findtype
switch "$type"
case 'a' 'audio'
set script finda
set type audio
case 'c' 'compressed' 'archive'
set script findc
set type compressed
case 'd' 'directory'
set script findd
set type directory
case 'i' 'image'
set script findi
set type image
case 'm' 'media'
set script findmedia
set type media
case 'u' 'unsorted'
echo "findtype does not support \"unsorted\"; just use findu instead."
exit 1
# set script findu
# set type unsorted
case 'v' 'video'
set script findv
set type video
case 'vis' 'visual'
set script findvis
set type visual
case '*'
echo "findtype does not support \"$type\"."
exit 1
end
set argv $argv[2..]
if set -q _flag_h
echo -n "$script - Find "
if test "$type" = 'directory'
echo "directories."
else if test -z "$type"
echo "files of a specified type."
else
echo "$type files."
end
echo "Usage: $script [arguments]"
echo
echo " -h/--help - Print help and exit."
echo " -d/--dotfiles - Also print files whose name starts with a period."
echo
echo "Any unknown arguments are passed to bfs or find."
exit
end
if not set -q _flag_d
set -- dotargs -not -iname '.*'
end
set find bfs
if not command -qs bfs
set find find
end
command $find $argv $dotargs \( (filter --print=find "$type" ) \)