Skip to content

Instantly share code, notes, and snippets.

@emilfolino
Created December 3, 2018 13:18
Show Gist options
  • Save emilfolino/68283d4887589b67f41c9a7143934faa to your computer and use it in GitHub Desktop.
Save emilfolino/68283d4887589b67f41c9a7143934faa to your computer and use it in GitHub Desktop.
function _makefile_targets {
local curr_arg;
local targets;
# Find makefile targets available in the current directory
targets=''
if [[ -e "$(pwd)/Makefile" ]]; then
targets=$( \
grep -oE '^[a-zA-Z0-9_-]+:' Makefile \
| sed 's/://' \
| tr '\n' ' ' \
)
fi
# Filter targets based on user input to the bash completion
curr_arg=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "${targets[@]}" -- $curr_arg ) );
}
complete -F _makefile_targets make
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
alias git='LANG=en_US.UTF-8 git'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment