gradle-completion
gradle-completion copied to clipboard
gw completion not working on Linux
It would be nice if the completion worked for https://github.com/dougborg/gdub (or something similar)
@rwinch gw should be completed the same as gradle achieved by commits 55303d5758f4eb8829f24dc724602e1fb8d0ba95 (zsh) and 146823068a63f1dcdc0686568fb39813bb8391d4 (bash)
If for some reason that's not working for you, could you please tell me a bit about your environment and exactly what command you're trying to complete so I can help debug?
Please note that these scripts don't yet support completion from a subproject directory #3.
Thanks for the fast reply!
I am using zsh 5.2 (x86_64-ubuntu-linux-gnu). I have the lastest oh-my-zsh installed but I have disabled all plugins.
The project I'm using leverages Gradle 3.3. If I type:
./gradlew --v
and press tab it completes to
./gradlew --version
If I type:
gw --v
and press tab nothing happens.
Thanks for the thorough context, Rob.
gw --v[TAB] completes correctly for me on macOS. I'll need to check my linux VM soon.
In the meantime, would you tell me if task completion works with gw?
@eriwen Thanks again for your fast response.
Task completion works for ./gradlew, but pressing gw [TAB] makes it autocomplete my path instead of tasks.
It may be useful to know I am using Ubuntu 16.10.
NOTE: I am running this in the root project of spring framework's master branch with sha f2967467e08a969a4e338c7b9a342bb2dda7f971
@rwinch Weird question: Does completion complete --status for you?
@eriwen No it does not. The following does not complete:
gw --statu[TAB]
However the following will complete:
./gradlew --statu[TAB]
So will the following
gradle --statu[TAB]
I'm able to reproduce this issue, and it seems like gw completion is being overridden. If I hit Ctrl-X ? instead of [tab] I get debug output that shows that completion is ignored and defaults to completing files.
I expect that explicitly declaring gw completion in ~/.zshrc with zstyle may do the trick. I can dig up the command for this after a bit.
Thanks for the follow up :)
when gw is an alias, it could also be completed if we check it with type:
if hash gw 2>/dev/null; then
complete -F _gradle gw
elif type gw &>/dev/null; then
complete -F _gradle gw
fi
The only issue is that it's not guaranteed to be an alias for gradlew, so the output of the type command might have to be parsed to guarantee we complete on the correct alias:
✘ 13:53 ~/git/platform-infrastructure [ bugfix/INFRA-3119 | ⚑ 8 ] $ type gw
gw is aliased to ./gradlew'`
Adding
compdef gw='gradle'
to ~/.zshrc seems to do the trick for me.
@eriwen Any news on this? Can't the workraound that @wolfs mentioned to work either. So basically I never use the completion since gw is sp much better than "./gradlew". I also tend to have my gw aliased to this function:
function build_gradlew() {
if [[ -f ../gradlew ]]; then
nice -n11 ../gradlew "$@";
else
nice -n11 ./gradlew "$@";
fi
};
But even when removing this, I can't get it to work.
https://github.com/gradle/gradle-completion/commit/35b500add1db1ca671f4a62d384927f631f74b88
This was implemented in bash last june. Not sure about zsh support.
@wolfs 's solution https://github.com/gradle/gradle-completion/issues/14#issuecomment-321808909 still works for me, and is the only work around I found so far.
I tried running the if branch directly
if hash gw 2>/dev/null || alias gw >/dev/null 2>&1; then echo yes; fi
# output:
yes
So this line has been already executed complete -F _gradle gw
Don't know what's wrong. Maybe it's a conflict with some other programs.
I'm using Macbook Pro macOS Mojave 10.14.3 zsh 5.5.1 (x86_64-apple-darwin17.5.0)