* Completion functions for Mac OS X
@ 2004-07-22 10:57 Motoi Washida
2004-07-22 12:48 ` Motoi Washida
0 siblings, 1 reply; 2+ messages in thread
From: Motoi Washida @ 2004-07-22 10:57 UTC (permalink / raw)
To: zsh-workers
Hi all,
Did anyone whotre completion scripts for commands on Mac OS X? I
couldn't
find such scripts, so I wrote some scripts. But I found someone tried to
do the same thing on this list today.
--
Motoi Washida
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Completion functions for Mac OS X
2004-07-22 10:57 Completion functions for Mac OS X Motoi Washida
@ 2004-07-22 12:48 ` Motoi Washida
0 siblings, 0 replies; 2+ messages in thread
From: Motoi Washida @ 2004-07-22 12:48 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
Here are the scripts. I also have another script (hdiutil), though it is
not completed yet.
On 2004/07/22, at 19:57, Motoi Washida wrote:
> Hi all,
>
> Did anyone whotre completion scripts for commands on Mac OS X? I
> couldn't
> find such scripts, so I wrote some scripts. But I found someone tried
> to
> do the same thing on this list today.
>
> --
> Motoi Washida
>
--
Motoi Washida
[-- Attachment #2: _mac_applications --]
[-- Type: application/octet-stream, Size: 1636 bytes --]
#autoload
_mac_applications_caching_policy () {
# rebuild if cache is more than a day old
oldp=( "$1"(Nmw+1) )
(( $#oldp ))
}
_mac_applications() {
[[ $PREFIX = */* ]] && return 1
local cache_policy
zstyle -s ":completion:*:*:$service:*" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:*:*:$service:*" cache-policy _mac_applications_caching_policy
fi
if ( [[ ${+apps} -eq 0 ]] || _cache_invalid Mac_applications ) \
&& ! _retrieve_cache Mac_applications; then
local app_pattern="*.app"
local -a app_path
zstyle -s ":completion:${curcontext}:commands" application-dir app_path
if [[ -z "$app_path" ]]; then
local -a apdptn
apdptn="((*~$app_pattern~Data~plugins~*Fonts~Contents)/)#"
app_path=({{/,/Developer,/Network,"$HOME"}/Applications/,"/Applications (Mac OS 9)/"}${~apdptn} "$HOME"/Desktop/{,*~${~app_pattern}(/)})
#app_path=({/,/Developer,/Network,"$HOME"}/Applications/${~apdptn} "$HOME"/Desktop/{,*~${~app_pattern}(/)})
fi
local -a apps
if ! zstyle -t ":completion:${curcontext}:commands" ignore-extention; then
apps=("${apps[@]}" "${app_path[@]}"/${~app_pattern})
fi
if ! zstyle -t ":completion:${curcontext}:commands" ignore-cfm; then
local capps
capps="`awk '/^Joy\!peffpwpc/ {print FILENAME; }; { nextfile }' ${app_path}/(*~*.?~*.??~*.???~*.????)(^/)`"
apps=("${apps[@]}" "${(f)capps}")
fi
typeset -U apps
apps=("${apps[@]:t:r}")
_store_cache Mac_applications apps
fi
local expl
_wanted commands expl 'mac os x applications' compadd $apps
}
[-- Attachment #3: Type: text/plain, Size: 2 bytes --]
[-- Attachment #4: _open --]
[-- Type: application/octet-stream, Size: 292 bytes --]
#compdef open
_open_mac_applications(){
_mac_applications || _files
}
_open() {
local context state line
typeset -A opt_args
_arguments\
'-a[specify application]:specify application:_open_mac_applications'\
'-e[open with TextEdit]'\
'*:files:_files'
}
[-- Attachment #5: Type: text/plain, Size: 2 bytes --]
[-- Attachment #6: _defaults --]
[-- Type: application/octet-stream, Size: 1573 bytes --]
#compdef defaults
_defaults_domains(){
local str="`defaults domains`"
local expl
local -a list
list=(${(s/, /)str} -g -globalDomain)
_wanted domains expl 'defaults database domains' \
compadd -M 'r:|.=* r:|=*' -- $list
}
_defaults_keys(){
echo $@[$#]
local ks="`defaults read "$words[2]" 2>& /dev/null | sed '/^ [[:alpha:]"]/ { s/^ //; s/ = .*$//; p;}; d'`"
local expl
_wanted keys expl '' compadd ${(f)ks}
}
_defaults(){
local -a _1st_arguments
_1st_arguments=(read read-type write rename delete domains find help)
local context state line expl
local -A opt_args
_arguments -A '-*' \
'(-currentHost)-host: :_hosts' \
'(-host)-currentHost' \
'*::command:->subcmd' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "commands" _1st_arguments
return
fi
case $words[1] in
read|read-type|delete)
_arguments \
"(1)-app: :_mac_applications" \
"(-app)1:domain:_defaults_domains" \
"2:keys:_defaults_keys"
;;
write)
_arguments \
"(1)-app: :_mac_applications" \
"(-app)1:domain:_defaults_domains" \
"2:key:_defaults_keys" \
"*::value:"
;;
rename)
_arguments \
"(1)-app: :_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
}
[-- Attachment #7: Type: text/plain, Size: 1 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-22 12:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-22 10:57 Completion functions for Mac OS X Motoi Washida
2004-07-22 12:48 ` Motoi Washida
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).