Skip to content

Instantly share code, notes, and snippets.

@megaserg
Created July 15, 2015 19:06
Show Gist options
  • Save megaserg/85ec4d732e9d940dced0 to your computer and use it in GitHub Desktop.
Save megaserg/85ec4d732e9d940dced0 to your computer and use it in GitHub Desktop.
Usage: source ~/setup-pants-completion.sh
_pants_goal_completion() {
# invoke pants to list goals
local pants_command=${COMP_WORDS[0]}
local goals_array=$(PANTS_NO_TRANSLATION=1 $pants_command -q goals | grep -v "Installed goals" | cut -d ":" -f 1 | sed -e 's/^[[:space:]]*//')
# ...or use a precomputed list
#local goals_array="autoblame bash-completion binary bootstrap builddict buildprops bundle changed check_published_deps clean-all clean-all-async compile compile-changed compute-buildprops deferred-sources dependees dependees_owners dependencies depmap detect-duplicates doc eclipse ensime export filedeps filemap filter gen goals idea invalidate jar killserver list markdown minimize ng-killall path pathdeps paths publish repl repl-dirty resolve roots run run-dirty server setup-py sort targets test test-changed thrift-linter unpack-jars"
local prefix=${COMP_WORDS[COMP_CWORD]}
if [[ $prefix == *"/"* ]]; then
# default to directory names matching
COMPREPLY=()
return 0
fi
COMPREPLY=( $(compgen -W "$goals_array" -- $prefix) )
}
complete -o dirnames -F _pants_goal_completion pants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment