Skip to content

Commit

Permalink
handle multi-targets case
Browse files Browse the repository at this point in the history
  • Loading branch information
braineo committed Oct 4, 2024
1 parent 613f6d7 commit 1efc948
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/completers/make.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ _fzf_complete_make() {
_fzf_complete_make-target() {
local fzf_options=$1
shift
# handles target matching
# 1. single target like `single_target:`
# 2. multiple targets on a line `bigoutput littleoutput median : `
# 3. proper exclude variable assigment `var := `

_fzf_complete --ansi --tiebreak=index ${(Q)${(Z+n+)fzf_options}} -- "$@" < <(grep -P '^[a-zA-Z_-]+:(?!=).*?$$' Makefile 2> /dev/null | uniq | awk -F ':' '{ print $1 }')
_fzf_complete --ansi --tiebreak=index ${(Q)${(Z+n+)fzf_options}} -- "$@" < <(grep -E '^(([a-zA-Z_-]+)\s*?)*:([^=]|$).*?$' Makefile | 2> /dev/null | uniq | awk -F ':' '{ split($1, arr, " "); for (i in arr) print arr[i] }')
}

0 comments on commit 1efc948

Please sign in to comment.