about summary refs log tree commit diff
path: root/Completion/Builtins/_compdef
blob: df25d44de9a9bed6acd20839d885d39ce0d8ebd9 (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
#compdef compdef

local expl func base=2

while [[ $words[base] = -* ]]; do
  case $words[base] in
    -d) delete=yes ;;
    -p) type=pattern ;;
    -k) type=key ;;
  esac  
  (( base++ ))
done

if [ "$delete" ]; then
  _tags any:argument commands || return 1

  _description expl 'completed command'
  compadd "$expl[@]" - ${(k)_comps}
else
  if [[ CURRENT -eq base ]]; then
    _tags any:argument functions || return 1

    _description expl 'completion function'
    compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t)
  else
    _command_names
  fi
fi