about summary refs log tree commit diff
path: root/Completion/Builtins/_zpty
blob: de793c814601c1084ce331d65d10e5a3e0251f77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#compdef zpty

local state line list names expl curcontext="$curcontext"
typeset -A opt_args

_arguments -C -s \
  '(-r)*::args:_normal' \
 - eb \
  '-e[echo input characters]' \
  '-b[io to pseudo-terminal blocking]' \
 - d \
  '-d[delete command]:*:name:->name' \
 - w \
  '-w[send string to command]:name:->name:*:strings to write' \
 - L \
  '-L[list defined commands as calls]' \
 - r \
  '(*)-r[read string from command]:name:->name:param:_parameters' && return 0

if [[ $state = name ]]; then
  if ! zmodload -e zsh/zpty; then
    _message "zpty module not loaded"
    return 1
  fi
  list=( ${${(f)"$(zpty)"}#*\) } )
  names=( ${list%%:*} )
  if zstyle -T ":completion:${curcontext}" verbose; then
    zformat -a list ' --' ${${(f)"$(zpty)"}#*\) }
    _wanted names expl 'zpty command names' compadd -d list - "$names[@]"
  else
    _wanted names expl 'zpty command names' compadd - "$names[@]"
  fi
fi