about summary refs log tree commit diff
path: root/Completion/User/_make
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_make')
-rw-r--r--Completion/User/_make24
1 files changed, 22 insertions, 2 deletions
diff --git a/Completion/User/_make b/Completion/User/_make
index 4770c0d7a..add58dbf0 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -1,4 +1,24 @@
 #compdef make gmake pmake
 
-compgen -s "\$(awk '/^[a-zA-Z0-9][^\/ 	]+:/ {print \$1}' FS=: [mM]akefile /dev/null)" ||
-_files
+local prev="$words[CURRENT-1]" file ret=1
+
+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
+
+  [[ -n "$file" ]] &&
+    compadd - $(awk '/^[a-zA-Z0-9][^/ 	]+:/ {print $1}' FS=: $file) && ret=0
+  (( ret )) && _files
+fi