MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //proc/3/root/usr/share/zsh/4.2.6/functions/_open
#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 "$PREFIX[1]" -W /
}

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

  _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
    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]" || -n "$words[(r)-f]" ]]; 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 "$@"