zsh-workers
 help / color / mirror / code / Atom feed
* Completion for Mac OS X again
@ 2004-08-19 13:20 Motoi Washida
  2004-08-20  1:24 ` lists
  0 siblings, 1 reply; 2+ messages in thread
From: Motoi Washida @ 2004-08-19 13:20 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

Hi.

I made completion for hdiutil.

I also have new completion for Mac OS X "open" command. It completes
faster and more correctly, and also completes files for the specified
application (ie. image files for "Preview", html files for "Safari" )

--
Motoi Washida


[-- Attachment #2: _mac_files_for_application --]
[-- Type: application/octet-stream, Size: 2000 bytes --]

#autoload

_mac_rsrc_check() {
  [[ ! -s "$REPLY/..namedfork/rsrc" ]] && return 1
  if [[ -x /Developer/Tools/GetFileInfo ]]; then
    local ftype="$(command /Developer/Tools/GetFileInfo -t $REPLY)"
    ftype="${ftype//\"/}"
    [[ -n "$types[(r)$ftype]" ]]
  else
      grep --quiet "\(${(j/\|/)types}\)" "$REPLY/..namedfork/rsrc"
  fi
}

_mac_parse_info_plist() {
  # For now, awk is used because builtin function "read" was too slow.
  # '<' is used for the delimiter because some Info.plist files use CR as
  # newline but read doesn't treat them as so
  local s='
    BEGIN { RS="<" }
      /^key>/ { sub(/key>/, ""); reading_key=$0 }
      /^string>/ {
        sub(/string>/, "")
        if (reading_key == "CFBundleTypeExtensions") exts=exts " \"" $0 "\""
        if (reading_key == "CFBundleTypeOSTypes") types=types " \"" $0 "\""
      }
      END {
        print "exts=(" exts ")\ntypes=(" types ")"
      }
    '
    command awk $s "$app_path/Contents/Info.plist" | while read; do
      eval "$REPLY"
    done
}

# Try to complete files for the specified application.
_mac_files_for_application() {
  local -a opts
  zparseopts -D -a opts q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:

  local app_path
  _retrieve_mac_apps
  app_path="${_mac_apps[(r)*/$1(|.app)]:-$1}"

  local -a glob_patterns
  glob_patterns=()

  # Try to get extentions from "Info.plist" XML file.
  if [[ -f "$app_path/Contents/Info.plist" ]]; then
    local -a exts types
    _mac_parse_info_plist

    if [[ -n "$exts[(r)\*]" ]]; then
      glob_patterns=( "*" )
    else
      if (( #exts != 0 )); then
        glob_patterns+=( "*.(${(j/|/)exts})(N)" )
      fi

      if (( #types != 0 )); then
        glob_patterns+=( "^*.[[:alnum:]]##(.Ne:_mac_rsrc_check:)" )
      fi
    fi
  else
    glob_patterns=( "*" )
  fi

  case ${#glob_patterns} in
    0) return 1 ;;
    1) _files "$opts[@]" -g "$glob_patterns[0]" ;;
    *) _files "$opts[@]" -g "{${(j/,/)glob_patterns}}" ;;
  esac
}

_mac_files_for_application "$@"

[-- Attachment #3: _retrieve_mac_apps --]
[-- Type: application/octet-stream, Size: 2008 bytes --]

#autoload

# Find paths of applications and preserve them into _mac_apps.
# Used by _mac_applications and _mac_files_for_application.

_mac_apps_caching_policy () {
   # Rebuild if cache is more than a day old
   oldp=( "$1"(Nmw+1) )
   (( $#oldp ))
}

_retrieve_mac_apps() {
  local cache_policy
  zstyle -s ":completion:*:*:$service:*" cache-policy cache_policy
  if [[ -z "$cache_policy" ]]; then
    zstyle ":completion:*:*:$service:*" cache-policy _mac_apps_caching_policy
  fi

  if ( [[ ${+_mac_apps} -eq 0 ]] || _cache_invalid Mac_applications ) \
        && ! _retrieve_cache Mac_applications; then

    # Get directories which may contain applications
    typeset -aU app_dir 
    if [[ -z "$app_dir" ]] && \
      ! zstyle -s ":completion:${curcontext}:commands" application-dir app_dir
    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} )
      typeset app_dir_pattern
      app_dir_pattern="(^(#i)(${(j/|/)app_dir_stop_pattern}))"
      app_dir=( ${^app_dir_root}/(${~app_dir_pattern}/)#(N) )
    fi

    typeset -g -Ua _mac_apps
    local -a app_result

    # Get application bundles
    if ! zstyle -t ":completion:${curcontext}:commands" ignore-bundle; then
      app_result=( ${^app_dir}*/Contents/(MacOS|MacOSClassic)(N) )
      _mac_apps+=( ${app_result[@]%/Contents/MacOS*} )
    fi

    # Get classic application files
    if ! zstyle -t ":completion:${curcontext}:commands" ignore-classic; 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)"
      _mac_apps+=( ${${(f)app_result}%/..namedfork/rsrc} )
    fi

    _store_cache Mac_applications _mac_apps
  fi
}

_retrieve_mac_apps "$@"

[-- Attachment #4: _open --]
[-- Type: application/octet-stream, Size: 999 bytes --]

#compdef open

_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 /
}

_open() {
  local curcontext="$curcontext" state line expl

  _arguments -C \
    '-a[specify application]: :->open_mac_applications' \
    '-e[open with TextEdit]' \
    '*: :->open_files'

  case "$state" in
    open_mac_applications)
      _alternative \
        "commands: :_mac_applications" \
        "files:: _open_absolute_application_path"
      ;;
    open_files)
      local app
      if [[ -n "$words[(r)-a]" ]]; then
        app="${(Q)words[words[(i)-a] + 1]}"
      elif [[ -n "$words[(r)-e]" ]]; then
        app="Text Edit"
      fi
      if [[ -n "$app" ]]; then
        _wanted files expl "file for $app" _mac_files_for_application "$app"
      else
        _webbrowser
      fi
      ;;
  esac
}

_open "$@"

[-- Attachment #5: _mac_applications --]
[-- Type: application/octet-stream, Size: 252 bytes --]

#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
}

_mac_applications "$@"

[-- Attachment #6: _hdiutil --]
[-- Type: application/octet-stream, Size: 22495 bytes --]

#compdef hdiutil

# utilities
#
_hdiutil_disk() {
  local -a disk_desc
  _call_program disks /bin/df | 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 )
    fi
  done
  _describe -t devices disks disk_desc
}

_hdiutil_device() {
  local -a device_desc
  _call_program devices /usr/bin/hdiutil burn -list | while read; do
    if [[ "$REPLY" == [:space:]#IOService:* ]]; then
      device_desc+=( "$REPLY" )
    fi
  done
  local expl
  _wanted devices expl device compadd "$device_desc[@]"
}

_hdiutil_imagesize(){
  local -a arr
  local num="${PREFIX%%[^0-9]*}"
  if [[ -n "$num" ]]; then
    arr=(
      "$num"b:"$(($num / 2.**11)) mega bytes"
      "$num"k:"$(($num / 2.**10)) mega bytes"
      "$num"m:"$(($num)) mega bytes"
      "$num"g:"$(($num)) giga bytes"
      "$num"t:"$(($num * 2**10)) giga bytes"
      "$num"p:"$(($num * 2**20)) giga bytes"
      "$num"e:"$(($num * 2**30)) giga bytes"
    )
  
    local expl
    _describe -t values "size (b, k, m, g..)" arr -V1
  else
    _message "size (b, k, m, g..)"
  fi
}

_hdiutil_imageformat(){
  local -a fmts
  fmts=(
    "UDRW:UDIF read/write image"
    "UDRO:UDIF read-only image"
    "UDZO:UDIF zlib-compressed image"
    "UDCO:UDIF ADC-compressed image"
    "UFBI:UDIF entire image with MD5 checksum"
    "UDTO:DVD/CD-R master for export"
    "UDxx:UDIF stub image"
    "UDSP:SPARSE (growable with content)"
    "Rdxx:NDIF read-only image (Disk Copy 6.3.3 format)"
    "DC42:Disk Copy 4.2 image"
  )
  ofmts=(
    "UDRo:UDIF read-only"
    "UDCo:UDIF compressed"
    "RdWr:NDIF read/write image"
    "ROCo:NDIF compressed image"
    "Rken:NDIF compressed"
  )
  _describe -t types "image format" fmts -V1 ||
  _describe -t types "obsolete/deprecated image format" ofmts -V1 
}

_hdiutil(){
  local -a _common_options
  _common_options=(
    '(: -)'-help'[display help message of a verb]'
    '(-quiet)-verbose' '(-verbose debug)-quiet' '(-quiet)-debug'
  )

  local -A _common_usage_options
  _common_usage_options=(
    -shadow "-shadow:shadow file:_files -g \*.shadow"
    -encryption "-encryption:encryption method:(CEncryptedEncoding)"
    -stdinpass "-stdinpass[specify password from standard input]"
    -certificate "-certificate[secondary access certificate]:certificate file:_files"
    -cacert "-cacert[certificate authority certificate]: :_files"
    -imagekey "*-imagekey[image key]:: :->keyvalue"
    -srcimagekey "*-srcimagekey[source image key]:: :->keyvalue"
    -tgtimagekey "*-tgtimagekey[target image key]:: :->keyvalue"
    -insecurehttp "-insecurehttp[ignore SSL host validation failure]"
    -plist "-plist[display output in plist format]"
    -recover "-recover[keychain to unlock]:keychain file:_files -g \*.keychain"
  )

  local -a _1st_arguments
  _1st_arguments=(
    'help:display minimal usage information'
    'attach:attach a disk image'
    'mount:attach a disk image'
    'detach:detach a disk image'
    'eject:detach a disk image'
    'verify:verify the checksum of a disk image'
    'create:create a disk image'
    'convert:convert a disk image into another format'
    'burn:burn image to optical media'
    'makehybrid:generate cross-platform hybrid images'
    'compact:compacts a SPARSE disk image'
    'info:display information about the disk image driver and attached images'
    'load:manually load the disk image driver'
    'checksum:calculate the specified checksum on the image data'
    'chpass:change the passphrase for an encrypted image'
    'unflatten:extract any UDIF metadata into resource fork'
    'flatten:embed any resource fork into UDIF data fork'
    'hfsanalyze:print information about an HFS/HFS+ volume'
    'mountvol:mount a volume'
    'unmount:unmount a volume'
    'imageinfo:print out information about a disk image'
    'plugins:print information about DiskImages framework plugins'
    'internet-enable:enable or disable post-processing for the image'
    'resize:resize partition or image'
    'segment:segment disk image'
    'pmap:display the partition map'
  )

  local size_spec='-size -sectors -megabytes -srcfolder -srcdir'

  #
  local curcontext="$curcontext" state line expl
  local -A opt_args

  _arguments -C '*:: :->subcmds'

  if (( CURRENT == 1 )); then
    _describe -t commands "hdiutil subcommands" _1st_arguments
    return
  fi

  case "$words[1]" in
    attach|mount)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-imagekey]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-plist]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-recover]" \
        "(-readwrite)-readonly[force the resulting device to be read-only]" \
        "(-readonly)-readwrite[attempt to set the device to be read/write]" \
        "(-nokernel)-nokernel[attach with/without a helper process]" \
        "(-kernel)-kernel[attach with/without a helper process]" \
        "-notremovable[prevent this image from being detached]" \
        "(-nomount)-mount[indicate whether image should be mounted]:mount?:(required optional suppressed)" \
        "(-mount)-nomount[indicate whether image should be mounted]" \
        "-mountroot[mount volumes in specified path]: :_directories" \
        "-mountpoint[mount volume at specified path]: :_directories" \
        "-union[perform a union mount]" \
        "-private[suppress mount notifications to the rest of the system]" \
        "-nobrowse[mark the volumes non-browsable in applications]" \
        "-owners[enable or disable owners for HFS+ volumes]: :(on off)" \
        "*-drivekey[key/value pair in the IOKit registry]:key=value:" \
        "(-noverify)-verify[verify image checksums]" \
        "(-verify)-noverify" \
        "(-noignorebadchecksums)-ignorebadchecksums[indicate bad checksums should be ignored]" \
        "(-ignorebadchecksums)-noignorebadchecksums" \
        "(-noidme)-idme[perform IDME actions]" \
        "(-idme)-noidme" \
        "(-noidmereveal)-idmereveal[reveal the results of IDME processing]" \
        "(-idmereveal)-noidmereveal" \
        "(-noidmetrash)-idmetrash[put IDME images in the trash after processing]" \
        "(-idmetrash)-noidmetrash" \
        "(-noautoopen)-autoopen[auto-open volumes after attaching an image]" \
        "(-autoopen)-noautoopen" \
        "(-noautoopenro)-autoopenro[auto-open read-only volumes]" \
        "(-autoopenro)-noautoopenro" \
        "(-noautoopenrw)-autoopenrw[auto-open read/write volumes]" \
        "(-autoopenrw)-noautoopenrw" \
        "1:disk image to attach:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    detach|eject)
      _arguments \
        "$_common_options[@]" \
        "-force[unmount any filesystems and detaches the image]" \
        "1: :_hdiutil_disk" && return 0
      ;;
    verify)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-imagekey]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-plist]" \
        "1:disk image to verify:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    create)
      local fold_opts="-format -crossdev -nocrossdev -scrub -noscrub"
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-imagekey]:" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-tgtimagekey]" \
        "$_common_usage_options[-plist]" \
        "($size_spec $fold_opts)-size[specify size]: :_hdiutil_imagesize" \
        "($size_spec $fold_opts)-sectors[specify size]:512 byte sectors" \
        "($size_spec $fold_opts)-megabytes[specify size]:mega bytes" \
        "($size_spec)-srcfolder[specify directory]: :_directories" \
        "($size_spec)-srcdir[specify directory]: :_directories" \
        "-align[size to which partition is aligned]:size" \
        "-type[image type]:image type:(UDIF SPARSE)" \
        "-fs[filesystem to make]:filesystem:(HFS+ HFS+J HFSX HFS MS-DOS UFS)" \
        "-volname[volume name]:name" \
        "-uid[uid of root directory]:uid in number" \
        "-gid[gid of root directory]:gid in number" \
        "-mode[mode of root directory]:mode" \
        "-nouuid[suppress addiing a UUID]" \
        "(-noautostretch)-autostretch" \
        "(-autostretch)-noautostretch" \
        "-stretch[max_stretch]: :_hdiutil_imagesize" \
        "-fsargs[additional arguments to pass to newfs]:arguments" \
        "-layout[partition layout]:partition layout:(NONE SPUD UNIVERSAL\ CD UNIVERSAL\ HD)" \
        "-partitionType[partition type]:partition type:(Apple_HFS Apple_UFS)" \
        "-ov[overwrite an existing file]" \
        "-attach[attach the image after creating it]" \
        "-format:format:_hdiutil_imageformat" \
        "(-nocrossdev)-crossdev[cross device boundaries when copying from the source]" \
        "(-crossdev)-nocrossdev" \
        "(-noscrub)-scrub[skip temporary files and trashes]" \
        "(-scrub)-noscrub" \
        "(-noanyowners)-anyowners[allow user files being copied]" \
        "(-anyowners)-noanyowners" \
        "1:disk image to create:_files" && return 0
        
      if [[ $state = keyvalue ]]; then
        _values 'key=value' \
          "di-sparse-puma-compatible:(TRUE FALSE)" \
          "di-shadow-puma-compatible:(TRUE FALSE)" \
          "encrypted-encoding-version:version:(1 2)" \
          "zlib-level:compression level:(1 2 3 4 5 6 7 8 9)" && return 0
      fi
      ;;
    convert)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-certificate]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-tgtimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "-align:size (512 byte sectors)" \
        "-segmentSize: :_hdiutil_imagesize" \
        "-pmap[add partition map]" \
        "-tasks[number of tasks for compression operation]:number:" \
        "-ov[overwrite an existing file]" \
        "-format:format:_hdiutil_imageformat" \
        "-o:target disk image:_files" \
        "1:source disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0

      if [[ $state = keyvalue ]]; then
        _values 'key=value' \
          "zlib-level:compression level:(1 2 3 4 5 6 7 8 9)" && return 0
      fi
      ;;
    burn)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "-device[device to use for burning]:device:_hdiutil_device" \
        "-testburn[don\'t turn on laser]" \
        "-anydevice[allow burning to devices not qualified by Apple]" \
        "(-eject)-noeject[don\'t eject disc after burning]" \
        "(-noeject)-eject" \
        "(-verifyburn)-noverifyburn[don\'t verify disc contents after burn]" \
        "(-noverifyburn)-verifyburn" \
        "(-addpmap)-noaddpmap[don\'t add partition map]" \
        "(-noaddpmap)-addpmap" \
        "(-skipfinalfree)-noskipfinalfree[don\'t skip final free partition]" \
        "(-noskipfinalfree)-skipfinalfree" \
        "(-nooptimizeimage)-optimizeimage[optimize filesystem for burning]" \
        "(-optimizeimage)-nooptimizeimage" \
        "-nounderrun[turn off buffer underrun protection]" \
        "-forceclose[force the disc to be closed after burning]" \
        "-speed[desired \"x-factor\"]:x_factor:(1 2 4 6 max)" \
        "-sizequery[calculate the required size without burning anything]" \
        "-erase[erase the media]" \
        "-fullerase[erase all sectors of the disc]" \
        "-list[list all burning devices with paths suitable for -device]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    makehybrid)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "-hfs[generate an HFS+ filesystem]" \
        "-iso[generate an ISO9660 filesystem with Rock Ridge extensions]" \
        "-joliet[generate Joliet extensions to ISO9660]" \
        "-hfs-blessed-directory[blessed folder for booting Mac OS X]: :_directories" \
        "-hfs-openfolder[folder automatically opened]: :_directories" \
        "-hfs-startupfile-size[Startup File size]:bytes" \
        "-abstract-file[path to an ISO9660/Joliet Abstract file]: :_file" \
        "-bibliography-file[path to a ISO9660/Joliet Bibliography file]: :_file" \
        "-copyright-file[path to a ISO9660/Joliet Copyright file]: :_file" \
        "-application[creator application name]:creator name" \
        "-preparer[data preparer name]:preparer name" \
        "-publisher[publisher name]:publisher name" \
        "-system-id[system identifier]:system identifier" \
        "-keep-mac-specific[keep Macintosh-specific files in non-HFS+ filesystems]" \
        "-default-volume-name[default volume name for all filesystems]:name" \
        "-hfs-volume-name[volume name for HFS+ filesystem]:name" \
        "-iso-volume-name[volume name for ISO9660 filesystem]:name" \
        "-joliet-volume-name[volume name for Joliet]:name" \
        "-hide-all[glob expression to hide]:glob expression" \
        "-hide-hfs[glob expression to hide in HFS+]:glob expression" \
        "-hide-iso[glob expression to hide in ISO9660]:glob expression" \
        "-hide-joliet[glob expression to hide in Joliet]:glob expression" \
        "-print-size[print size estimate and quit]" \
        "-plistin[accept command-line options as a plist on stdin]" \
        "-ov[overwrite an existing file]" \
        "(-noverify)-verify[verify image checksums]" \
        "(-verify)-noverify" \
        "(-nokernel)-nokernel[attach with a helper process]" \
        "(-kernel)-kernel[attach without a helper process]" \
        "-o:target disk image:_files" \
        "1:source disk image or directory:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    compact)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "1:sparse image:_files -g \*.sparseimage" && return 0
      ;;
    info)
      _arguments "$_common_options[@]" \
        "$_common_usage_options[-plist]" && return 0
      ;;
    load)
      _arguments "$_common_options[@]" && return 0
      ;;
    checksum)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "-type:image type:(UDIF-CRC32 UDIF-MD5 DC42 CRC28 CRC32 MD5)" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    chpass)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-recover]" \
        "$_common_usage_options[-srcimagekey]" \
        "-oldstdinpass[specify old password from standard input]" \
        "-newstdinpass[specify new password from standard input]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    unflatten)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    flatten)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "(-xml)-noxml[don\'t embed XML data for in-kernel attachment]" \
        "(-noxml)-xml" \
        "(-rsrcfork)-norsrcfork[don\'t embed resource fork data]" \
        "(-norsrcfork)-rsrcfork" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    hfsanalyze)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "1:disk image or device:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    mountvol)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-plist]" \
        "1: :_path_files -W /dev -g disk\*" && return 0
      ;;
    unmount)
      _arguments \
        "$_common_options[@]" \
        "-force[unmount filesystem regardless of open files]" \
        "1:device or mount point:_files" && return 0
      ;;
    imageinfo)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "-format[just print out the image format]" \
        "-checksum[just print out the image checksum]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;
    plugins)
      _arguments \
        "$_common_options[@]" "$_common_usage_options[-plist]" && return 0
      ;;
    internet-enable)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-plist]" \
        "(-yes -no -query)"{-yes,-no,-query} \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0
      ;;

    resize)
      _arguments -C \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "(-sectors)-size[specify size]: :_hdiutil_imagesize" \
        "(-size)-sectors[specify size]:size (512 byte sectors)/min/max:" \
        "-imageonly[only resize image file]" \
        "-partitiononly[only resize partition(s) in the image]" \
        "-partitionNumber[partition to resize]:partition number" \
        "-growonly[only allow the image to grow]" \
        "-shrinkonly[only allow the image to shrink]" \
        "-nofinalgap[allow elimination of trailing free partition]" \
        "-limits[displays min/current/max size]" \
        "1:disk image:_files -g \*.dmg\(\|.bin\)" \
        && return 0
      ;;
    segment)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-tgtimagekey]" \
        "$_common_usage_options[-plist]" \
        "(-segmentSize)-segmentCount[number of segments]:number" \
        "(-segmentCount)-segmentSize[segment size]: :_hdiutil_imagesize" \
        "-firstSegmentSize[first segment size]: :_hdiutil_imagesize" \
        "-restricted[make restricted segments]" \
        "-o[first segment name]:name" \
        "1:source disk image:_files -g \*.dmg\(\|.bin\)" \
        && return 0
      ;;
    pmap)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "-options[just print out the image checksum]: :->option" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)" \
        && return 0

      case "$state" in
        option)
          _values -s '' option \
            "r[process all without modification]" \
            "x[process 2K & 512 entries and merge]" \
            "s[return all quantities in sectors]" \
            "S[sort all entries by block number]" \
            "g[account for all unmapped space]" \
            "c[combine adjacent freespace entries]" \
            "f[extend last partition to device end]" \
            "v[synthesize single volumes as a single partition entry]" \
            "k[skip zero length entries]" \
            "K[skip all free & void partitions]" \
            "m[merge small free partitions into a previous partition]" \
            "i[ignore small free partitions caused by block alignment]"
          ;;
      esac
      ;;
    *)
      _message "unknown hdiutil command: $words[1]"
      _default
      ;;
  esac
  return 1
}

_hdiutil "$@"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Completion for Mac OS X again
  2004-08-19 13:20 Completion for Mac OS X again Motoi Washida
@ 2004-08-20  1:24 ` lists
  0 siblings, 0 replies; 2+ messages in thread
From: lists @ 2004-08-20  1:24 UTC (permalink / raw)
  To: zsh-workers; +Cc: Motoi Washida

Thank you!  If you ever decide to tackle /usr/sbin/diskutil please post  
the results.

-Ryan


On Aug 19, 2004, at 8:20 AM, Motoi Washida wrote:

> Hi.
>
> I made completion for hdiutil.
>
> I also have new completion for Mac OS X "open" command. It completes
> faster and more correctly, and also completes files for the specified
> application (ie. image files for "Preview", html files for "Safari" )
>
> --
> Motoi Washida
>
> <_mac_files_for_application><_retrieve_mac_apps><_open><_mac_applicatio 
> ns><_hdiutil>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-20  2:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-19 13:20 Completion for Mac OS X again Motoi Washida
2004-08-20  1:24 ` lists

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).