From 8605ba6dacb27d48be99fd762b54aaac1a6b4958 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 23 Jul 2004 13:37:42 +0000 Subject: Motoi Washida: 20179: new completions for Mac OS X --- Completion/Darwin/Type/.distfiles | 4 +++ Completion/Darwin/Type/_mac_applications | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Completion/Darwin/Type/.distfiles create mode 100644 Completion/Darwin/Type/_mac_applications (limited to 'Completion/Darwin/Type') diff --git a/Completion/Darwin/Type/.distfiles b/Completion/Darwin/Type/.distfiles new file mode 100644 index 000000000..bf2b38068 --- /dev/null +++ b/Completion/Darwin/Type/.distfiles @@ -0,0 +1,4 @@ +DISTFILES_SRC=' +.distfiles +_mac_applications +' diff --git a/Completion/Darwin/Type/_mac_applications b/Completion/Darwin/Type/_mac_applications new file mode 100644 index 000000000..69b23ea7b --- /dev/null +++ b/Completion/Darwin/Type/_mac_applications @@ -0,0 +1,51 @@ +#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}(/)}) + 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 application' compadd -a apps +} + +_mac_applications "$@" -- cgit 1.4.1