blob: 893cb0bc7cc767b73f2102b84ac86bb0a05dfbac (
plain) (
blame)
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
|
# Semi-intelligent completion for find(1); nothing too crazy
_find() {
# Iterate through completions produced by subshell
local ci comp
while IFS= read -r comp ; do
COMPREPLY[ci++]=$comp
done < <(
# Complete POSIX-specified options
case $2 in
(-*)
compgen -W '
-atime
-ctime
-depth
-exec
-group
-links
-mtime
-name
-newer
-nogroup
-nouser
-ok
-perm
-print
-prune
-size
-type
-user
-xdev
' -- "$2"
exit
;;
esac
# Look at the word *before* this one to figure out what to
# complete
case $3 in
# Args to -exec and -execdir should be commands
(-exec|-execdir) compgen -A command -- "$2" ;;
# Legal POSIX flags for -type
(-type) compgen -W 'b c d f l p s' -- "$2" ;;
# Args to -group should complete group names
(-group) compgen -A group -- "$2" ;;
# Args to -user should complete usernames
(-user) compgen -A user -- "$2" ;;
esac
)
}
complete -F _find -o bashdefault -o default find
|