blob: ea0ccf1dca1df4e86d0a87a6cf7d13db6aaca3e1 (
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
29
30
|
# Completion setup for Make, completing targets
_make() {
# Bail if no legible Makefile
[[ -r Makefile ]] || return 1
# Build a list of targets by parsing the Makefile
local -a targets tokens
local target line
while read -r line ; do
if [[ $line == *:* ]] ; then
target=$line
target=${target%%:*}
target=${target% }
if [[ $target != *[^[:alnum:][:space:]_-]* ]] ; then
IFS=' ' read -a tokens \
< <(printf '%s\n' "$target")
targets=("${targets[@]}" "${tokens[@]}")
fi
fi
done < Makefile
# Complete with matching targets
for target in "${targets[@]}" ; do
[[ $target == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
COMPREPLY=("${COMPREPLY[@]}" "$target")
done
}
complete -F _make -o default make
|