blob: ca5d87e6531a7bddc472ca0a9bcdce93f83d12da (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#compdef defaults
_defaults_domains(){
if [[ "`eval echo $PREFIX`" != [/~]* ]]; then
local str="$(_call_program domains defaults domains 2>/dev/null)"
local expl
local -a list
list=( ${(s/, /)str} -g -globalDomain )
_wanted domains expl 'defaults database domain' \
compadd -M 'r:|.=* r:|=*' -a list
else
_files -g '*.plist(-.:r)'
fi
}
_defaults_keys(){
local ks
ks=(${${${${(M)${(f)"$(defaults read "$words[2]" 2>/dev/null)"}:# [^ ]*=*}# }%% = *}:Q})
local expl
_wanted keys expl 'key' compadd "$ks[@]"
}
_defaults(){
local -a _1st_arguments
_1st_arguments=( read read-type write rename delete domains find help )
local curcontext="$curcontext" state line expl
typeset -A opt_args
_arguments -C -A '-*' \
'(-currentHost)-host:host:_hosts' \
'(-host)-currentHost' \
'*::command:->subcmd' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "command" _1st_arguments
return
fi
case $words[1] in
read|read-type|delete)
_arguments \
"(1)-app:application:_mac_applications" \
"(-app)1:domain:_defaults_domains" \
"2:keys:_defaults_keys"
;;
write)
_arguments \
"(1)-app:application:_mac_applications" \
"(-app)1:domain:_defaults_domains" \
"2:key:_defaults_keys" \
"*::value"
;;
rename)
_arguments \
"(1)-app:application:_mac_applications" \
"(-app)1:domain:_defaults_domains" \
"2:old key:_defaults_keys" \
"3:new key:_defaults_keys"
;;
domains|help)
;;
find)
_message word
;;
*)
_message "unknown defaults command: $words[1]"
;;
esac
}
_defaults "$@"
|