about summary refs log tree commit diff
path: root/Completion/Builtins/_compdef
blob: 4208c2689072fcba05edded7c10353bb29b75d38 (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
#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
  _description expl 'completed command'
  compadd "$expl[@]" - ${(k)_comps}
else
  if [[ CURRENT -eq base ]]; then
    _description expl 'completion function'
    compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t)
  else
    _command_names
  fi
fi