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