From: Motoi Washida <a66@h8.dion.ne.jp>
To: zsh-workers@sunsite.dk
Subject: Fink completion
Date: Fri, 12 Nov 2004 19:41:35 +0900 [thread overview]
Message-ID: <6CC830A4-3497-11D9-8EC5-000D93502E64@h8.dion.ne.jp> (raw)
[-- Attachment #1: Type: text/plain, Size: 387 bytes --]
Hi,
I wrote Fink completion. Fink is a package management system on Mac OS
X. Could you add this completion to main zsh trunk if there is no
problem?
William Scott and Wataru Kagawa gave me advices to complete correctly.
And could you add new completion I submitted before?
http://www.zsh.org/mla/workers/2004/msg00923.html
And I modified some files after that.
--
Motoi Washida
[-- Attachment #2: _fink --]
[-- Type: application/octet-stream, Size: 5350 bytes --]
#compdef fink
_fink_get_packages_with_cache(){
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy _finkpkgs_caching_policy
fi
typeset -g -a _fink_pkgs
local expl
if ( (( #_fink_pkgs == 0 )) || _cache_invalid finkpkgs) \
&& ! _retrieve_cache finkpkgs; then
_fink_pkgs=(${(f)"$(
command fink list --tab \
| command grep -v '\[virtual package\]' \
| command sed 's/^ / n /' \
| command cut -f1,2
)"})
_store_cache finkpkgs _fink_pkgs
fi
if (( # > 0 )); then
local i
for i in "$@"; do
case "$i" in
-i) packages+=(${${(M)_fink_pkgs:#?i?*}#* }) ;;
-o) packages+=(${${(M)_fink_pkgs:#(i)*}#* }) ;;
-n) packages+=(${${(M)_fink_pkgs:# n *}#* }) ;;
esac
done
else
packages=(${_fink_pkgs#* })
fi
}
_fink_get_packages_without_cache(){
local expl
packages=(${(f)"$(
command fink list -t "$@" "$PREFIX" \
| command grep -v '\[virtual package\]' \
| command cut -f2
)"})
}
_fink_get_packages(){
# variable packages will be set
if zstyle -t ":completion:${curcontext}:" use-cache; then
_fink_get_packages_with_cache "$@"
else
_fink_get_packages_without_cache "$@"
fi
}
_finkpkgs_caching_policy(){
oldp=( "$1"(Nmw+1) )
(( $#oldp )) ||
[[ /sw/var/cache/apt/pkgcache.bin -nt "$1" ]] ||
[[ /sw/var/lib/dpkg/available -nt "$1" ]]
}
_fink(){
local -a _1st_arguments
_1st_arguments=(
'install:install or update packages'
'remove:remove packages'
'purge:remove packages and configuration files'
'update-all:update all installed packages to the latest version'
'list:search package name or conditions and list'
'apropos:search package descriptions or conditions and list'
'describe:display a description of the package'
'fetch:download package source files'
'fetch-all:downloads all package source files'
'fetch-missing:download all missing package source files'
'build:build .deb packages'
'rebuild:rebuild .deb packages'
'reinstall:reinstall packages'
'configure:rerun the fink configuration process'
'selfupdate:upgrade to a new fink release'
'validate:validate files'
'scanpackages:call dpkg-scanpackages'
'checksums:validate the MD5 digest of all tarballs'
'cleanup:removes obsolete package files'
)
local context state line expl
local -A opt_args
_arguments \
'(-h --help)'{-h,--help}'[display help text]' \
'(-q --quiet)'{-q,--quiet}'[causes fink to be less verbose]' \
'(-V --version)'{-V,--version}'[display version information]' \
'(-v --verbose)'{-v,--verbose}'[causes fink to be more verbose]' \
'(-y --yes)'{-y,--yes}'[assume default answer for interactive questions]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "fink subcommand" _1st_arguments
return
fi
local -a packages
case "$words[1]" in
install|update|enable|activate|use)
_fink_get_packages -n -o
_wanted packages expl 'not installed or outdated fink package' compadd -a packages ;;
remove|disable|deactivate|unuse|delete|purge)
_fink_get_packages -i
_wanted packages expl 'installed package' compadd -a packages ;;
#update-all)
list)
_arguments \
'(-t --tab)'{-t,--tab}'[outputs list with tabs as field delimiter]' \
'(-i --installed)'{-i,--installed}'[packages currently installed]' \
'(-u --uptodate)'{-u,--uptodate}'[packages up to date]' \
'(-o --outdate)'{-o,--outdated}'[packages newer version is available]' \
'(-n --notinstalled)'{-n,--notinstalled}'[packages not installed]' \
'(-b --buildonly)'{-b,--buildonly}'[packages Build Only Depends]' \
'(-s --section)'{-s=,--section=}'[sections]:section name' \
'(-m --maintainer)'{-m=,--maintainer=}'[maintainer]:maintainer name' \
--tree='[tree]:tree name' \
'(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \
'(1 : -)'{-h,--help}'[display help text]' \
'1: :->pkgs' && return 0
if [[ "$state" == pkgs ]]; then
_fink_get_packages
_wanted packages expl 'package name hint' compadd -a packages
fi ;;
apropos)
_arguments \
'(-t --tab)'{-t,--tab}'[output the list with tabs as field delimiter]' \
'(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \
'(1 : -)'{-h,--help}'[display help text]' \
'1: :->pkgs' && return 0
if [[ "$state" == pkgs ]]; then
_fink_get_packages
_wanted packages expl 'package hint' compadd -a packages
fi ;;
describe|desc|description|info)
_fink_get_packages
_wanted packages expl 'package' compadd -a packages ;;
#fetch)
#fetch-all)
fetch-missing)
_arguments \
'(-i --ignore-restrictive)'{-i,--ignore-restrictive}'[do not fetch packages that are "License: Restrictive"]' ;;
#build)
rebuild|reinstall)
_fink_get_packages
_wanted packages expl 'package' compadd -a packages ;;
#configure)
#selfupdate)
validate|check)
_wanted files expl 'finkinfo file' _files -g \*.info ;;
#scanpackages)
#checksums)
#cleanup)
esac
}
_fink "$@"
[-- Attachment #3: completion_for_mac_2004_11_12.patch --]
[-- Type: application/octet-stream, Size: 4065 bytes --]
diff -dur /Users/wm3/Desktop/hoge/_hdiutil Command/_hdiutil
--- /Users/wm3/Desktop/hoge/_hdiutil Sat Oct 30 17:17:08 2004
+++ Command/_hdiutil Sat Nov 6 14:25:59 2004
@@ -4,11 +4,10 @@
#
_hdiutil_disk() {
local -a disk_desc
- _call_program disks /bin/df | while read; do
+ _call_program devices hdiutil info | while read; do
local disk_name="${${(M)REPLY[(w)1]%/dev/disk*}#/dev/}"
- local mount_point="/${REPLY#*%*/}"
- if [[ -n "$disk_name" && "$mount_point" != "/" ]]; then
- disk_desc+=( $disk_name:$mount_point )
+ if (( #disk_name )); then
+ disk_desc+=( "$disk_name:${${(M)REPLY% *}#?}" )
fi
done
_describe -t devices disks disk_desc
diff -dur /Users/wm3/Desktop/hoge/_open Command/_open
--- /Users/wm3/Desktop/hoge/_open Sat Oct 30 17:17:04 2004
+++ Command/_open Fri Nov 12 19:21:02 2004
@@ -3,8 +3,8 @@
_open_absolute_application_path() {
local expl curcontext
zstyle -T ":completion:${curcontext}:files" prefix-needed && \
- [[ "$PREFIX" != /* && compstate[nmatches] -ne 0 ]] && return 1
- _wanted files expl 'application file' _path_files -P / -W /
+ [[ "$PREFIX" != [/~]* && compstate[nmatches] -ne 0 ]] && return 1
+ _wanted files expl 'application file' _path_files -P "$PREFIX[1]" -W /
}
_open() {
@@ -13,6 +13,7 @@
_arguments -C \
'-a[specify application]: :->open_mac_applications' \
'-e[open with TextEdit]' \
+ '-f[Reads input from standard input and opens with TextEdit]' \
'*: :->open_files'
case "$state" in
@@ -25,7 +26,7 @@
local app
if [[ -n "$words[(r)-a]" ]]; then
app="${(Q)words[words[(i)-a] + 1]}"
- elif [[ -n "$words[(r)-e]" ]]; then
+ elif [[ -n "$words[(r)-e]" || -n "$words[(r)-f]" ]]; then
app="Text Edit"
fi
if [[ -n "$app" ]]; then
diff -dur /Users/wm3/Desktop/hoge/_mac_applications Type/_mac_applications
--- /Users/wm3/Desktop/hoge/_mac_applications Sat Oct 30 17:17:14 2004
+++ Type/_mac_applications Fri Nov 12 19:19:28 2004
@@ -1,15 +1,6 @@
#autoload
-_mac_applications() {
- [[ $PREFIX = */* ]] && return 1
-
- _retrieve_mac_apps
-
- local -a mac_apps
- mac_apps=( ${_mac_apps[*]:t:r} )
-
- local expl
- _wanted commands expl 'Mac OS X application' compadd -a mac_apps
-}
+_retrieve_mac_apps
-_mac_applications "$@"
+local expl
+_wanted commands expl 'Mac OS X application' compadd -- "${(@)${_mac_apps[@]:t}%.app}"
diff -dur /Users/wm3/Desktop/hoge/_retrieve_mac_apps Type/_retrieve_mac_apps
--- /Users/wm3/Desktop/hoge/_retrieve_mac_apps Sat Oct 30 21:49:30 2004
+++ Type/_retrieve_mac_apps Sat Nov 6 18:42:54 2004
@@ -26,7 +26,7 @@
then
typeset -a app_dir_stop_pattern app_dir_root
app_dir_stop_pattern=( "*.app" "contents#" "*data" "*plugins#" "*plug?ins#" "fonts#" "document[[:alpha:]]#" "*help" "resources#" "images#" "*configurations#" )
- app_dir_root=( {,/Developer,/Network,"$HOME"}/{Applications*,Desktop} )
+ app_dir_root=( {,/Developer,/Network,"$HOME"}/{Applications*(N),Desktop} )
typeset app_dir_pattern
app_dir_pattern="(^(#i)(${(j/|/)app_dir_stop_pattern}))"
app_dir=( ${^app_dir_root}/(${~app_dir_pattern}/)#(N) )
@@ -41,12 +41,14 @@
_mac_apps+=( ${app_result[@]%/Contents/MacOS*} )
fi
- # Get classic application files
- if ! zstyle -t ":completion:${curcontext}:commands" ignore-classic; then
+ # Get single file applications
+ if ! zstyle -t ":completion:${curcontext}:commands" ignore-single; then
autoload -U zargs
- local app_cand
- app_cand=( ${^app_dir}^*.[a-z]#(.UrN,.RN^U) )
- app_result="$(zargs --max-chars $((1024<<17)) ${^app_cand}/..namedfork/rsrc -- grep -l APPL)"
+ local app_cand nargs envvars
+ app_cand=( ${^app_dir}^*.[a-z]#/..namedfork/rsrc(.UrN,.RN^U) )
+ envvars="$(builtin typeset -x)"
+ nargs=$(( $(command sysctl -n kern.argmax) - $#envvars - 2048 ))
+ app_result="$(zargs --max-chars $nargs ${app_cand[@]} -- grep -l APPL)"
_mac_apps+=( ${${(f)app_result}%/..namedfork/rsrc} )
fi
[-- Attachment #4: Type: text/plain, Size: 1 bytes --]
next reply other threads:[~2004-11-12 10:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-12 10:41 Motoi Washida [this message]
2004-11-12 12:01 ` Peter Stephenson
2004-11-13 9:34 ` Motoi Washida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6CC830A4-3497-11D9-8EC5-000D93502E64@h8.dion.ne.jp \
--to=a66@h8.dion.ne.jp \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).