about summary refs log tree commit diff
path: root/Completion/User/_make
blob: 4c6095e95a979b04004576c52024a4282c892387 (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
#compdef make gmake pmake

local prev="$words[CURRENT-1]" file ret=1 expl

if [[ "$prev" = -[CI] ]]; then
  _files -/
elif [[ "$prev" = -[foW] ]]; then
  _files
else
  file="$words[(I)-f]"
  if (( file )); then
    file="$words[file+1]"
  elif [[ -e Makefile ]]; then
    file=Makefile
  elif [[ -e makefile ]]; then
    file=makefile
  else
    file=''
  fi

  _description expl 'make target'
  [[ -n "$file" ]] &&
    compadd "$expl[@]" - $(awk '/^[a-zA-Z0-9][^\/ 	]+:/ {print $1}' FS=: $file) && ret=0
  (( ret )) && { compset -P 1 '*\='; _files }
fi