1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 13:33:52 +01:00
zsh/Completion/Darwin/Command/_defaults
2004-07-23 13:37:42 +00:00

67 lines
1.6 KiB
Plaintext

#compdef defaults
_defaults_domains(){
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
}
_defaults_keys(){
local ks="$(_call_program keys defaults read "$words[2]" 2>/dev/null | sed '/^ [[:alpha:]"]/ { s/^ //; s/ = .*$//; p;}; d')"
local expl
_wanted keys expl 'key' compadd ${(f)ks}
}
_defaults(){
local -a _1st_arguments
_1st_arguments=( read read-type write rename delete domains find help )
local curcontext="$curcontext" state line expl
_arguments -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 "$@"