-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradle
27 lines (24 loc) · 829 Bytes
/
gradle
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
_gradle()
{
set +e
local cur=${COMP_WORDS[COMP_CWORD]}
_get_comp_words_by_ref -n : cur
local gradle_cmd="gradle -I /etc/gradle/completion.gradle"
local cache_dir="${GRADLE_USER_HOME-$HOME/.gradle}/completion"
mkdir -p $cache_dir
local commands=''
local gradle_files_checksum='absent'
if [[ -f build.gradle ]]; then
gradle_files_checksum="$(pwd | sed 's/\//1/g')-$(stat -c %Y build.gradle)"
fi
if [[ -f "$cache_dir/$gradle_files_checksum" ]]; then
commands=$(cat $cache_dir/$gradle_files_checksum)
else
commands=$($gradle_cmd -q bashCompletion | tr '\n' ' ')
commands=$(echo $commands | sed 's/:/\\:/g')
echo $commands > $cache_dir/$gradle_files_checksum
fi
COMPREPLY=( $(compgen -W "$commands" -- $cur) )
__ltrim_colon_completions "$cur"
}
complete -F _gradle gradle gradlew