From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93 invoked from network); 22 Jul 2004 12:51:03 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Jul 2004 12:51:03 -0000 Received: (qmail 20796 invoked from network); 22 Jul 2004 12:50:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Jul 2004 12:50:57 -0000 Received: (qmail 2011 invoked by alias); 22 Jul 2004 12:50:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20179 Received: (qmail 2001 invoked from network); 22 Jul 2004 12:50:44 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 22 Jul 2004 12:50:44 -0000 Received: (qmail 19619 invoked from network); 22 Jul 2004 12:48:46 -0000 Received: from mail1.ecc.u-tokyo.ac.jp (133.11.171.216) by a.mx.sunsite.dk with SMTP; 22 Jul 2004 12:48:43 -0000 Received: from spam005.ecc.u-tokyo.ac.jp (spam005.ecc.u-tokyo.ac.jp [133.11.50.198]) by mail1.ecc.u-tokyo.ac.jp (Postfix) with ESMTP id C2761704AC for ; Thu, 22 Jul 2004 21:48:36 +0900 (JST) Received: from [192.168.1.12] ( [222.5.113.76]) by spam005.ecc.u-tokyo.ac.jp (SpamBlock.pst 3.4.25) with ESMTP id <5F375244-DBDD-11D8-8A54-000D93502E64@h8.dion.ne.jp> for ; Thu, 22 Jul 2004 21:48:18 +0900 Mime-Version: 1.0 (Apple Message framework v618) In-Reply-To: References: Content-Type: multipart/mixed; boundary=Apple-Mail-19-524134271 Message-Id: <5F375244-DBDD-11D8-8A54-000D93502E64@h8.dion.ne.jp> From: Motoi Washida Subject: Re: Completion functions for Mac OS X Date: Thu, 22 Jul 2004 21:48:03 +0900 To: zsh-workers@sunsite.dk X-Mailer: Apple Mail (2.618) X-IP: 222.5.113.76 X-FROM-DOMAIN: h8.dion.ne.jp X-FROM-EMAIL: a66@h8.dion.ne.jp X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.9 required=6.0 tests=FROM_ENDS_IN_NUMS autolearn=no version=2.63 X-Spam-Hits: 0.9 --Apple-Mail-19-524134271 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed 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 --Apple-Mail-19-524134271 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="_mac_applications" Content-Disposition: attachment; filename=_mac_applications #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 } --Apple-Mail-19-524134271 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-19-524134271 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="_open" Content-Disposition: attachment; filename=_open #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' } --Apple-Mail-19-524134271 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-19-524134271 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="_defaults" Content-Disposition: attachment; filename=_defaults #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 } --Apple-Mail-19-524134271 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-19-524134271--