gradle / gradle-completion

Gradle tab completion for bash and zsh
MIT License
1.02k stars 131 forks source link

Basic installation doesn't work on macOS with zsh #95

Open ZacSweers opened 3 years ago

ZacSweers commented 3 years ago
❯ brew install gradle-completion

❯ echo $fpath | grep "/usr/local/share/zsh/site-functions"
/Users/zsweers/.oh-my-zsh/plugins/git /Users/zsweers/.oh-my-zsh/functions /Users/zsweers/.oh-my-zsh/completions /usr/local/share/zsh/site-functions /usr/share/zsh/site-functions /usr/share/zsh/5.7.1/functions

cd <our project>

❯ source ~/.zsh/gradle-completion/_gradle 1>&2 2>/dev/null; __gradle-completion-init
zsh: command not found: __gradle-completion-init

~/.zsh/gradle-completion doesn't exist, is there some undocumented intermediary step required?

mdemaso commented 3 years ago

Try quitting Terminal and re-opening it. This was a required step that I had to do to get it to work properly.

jkaan commented 3 years ago

The issue is that the manual install step would put the _gradle file in this spot: ~/.zsh/gradle-completion/_gradle. However, running brew install gradle-completion puts the file in /usr/local/share/zsh/site-functions/_gradle.

So if you run source /usr/local/share/zsh/site-functions/_gradle 1>&2 2>/dev/null; __gradle-completion-init. Then it'll work.

I ran into this same issue :).

Edit: Running ./gradlew will also generate the cache of course

tinder-haroldmartin commented 3 years ago

I am getting this error

% source /usr/local/share/zsh/site-functions/_gradle
_gradle:6: command not found: _arguments
__gradle_tasks:20: command not found: _describe

After which I can't get autocomplete working following the above steps or the troubleshooting steps in readme 😞

saket commented 2 years ago

I'm running into the same problem! Is homebrew not the recommended way to install gradle-completion?

qoomon commented 2 years ago

just add following snippet to your .zshrc

if [ $commands[brew] ]
then
  fpath=("$(brew --prefix)/share/zsh/site-functions" $fpath)
fi

see https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh