> `#{opt_pkgshare}/git-extras-completion.zsh`
Huh, didn't even know `opt_pkgshare` is a thing. I blame <https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md#variables-for-directory-locations>.
That said, `/usr/local/share/git-extras/git-extras-completion.zsh` looks so much nicer than `/usr/local/opt/git-extras/share/git-extras/git-extras-completion.zsh`.
> It does not require additional sourcing of the script in zsh as long as `/usr/local/share/zsh/site-functions` is in `$fpath`.
Well, Zsh does not automatically source everything in `$fpath`, or mark every function in every file as autoload... There are basically two ways to define a function: one, just define it, so you need to source the definition at some point; two, autoload it, the rule of which is documented very clearly [here](http://zsh.sourceforge.net/Doc/Release/Functions.html), and having a single file in fpath that defines a load of functions doesn't really work (unless it's a compiled `.zwc` file, which is another story).
The fact that you're able to complete `git extras`, i.e., you're able to load `_git-extras` somehow, is curious. You can find out where it's defined and when it's loaded with `type _git-extras`. Basically, start out fresh, do the following:
```console
$ type _git-extras # You should see the following if _git-extras is properly marked as autoload; if you see an actual path, then that path has already been sourced.
_git is an autoload shell function
$ git ext<tab>
$ type _git-extras # This time you should see the path, if the function is properly autoloaded.
_git-extras is a shell function from /usr/local/share/zsh/site-functions/git-extras-completion.zsh
```
Also, do you use any Zsh configuration framework? It could be doing something for you.
`git-extras-completion.zsh` isn't the usual, autoloadable type of zsh completion definition you see elsewhere. To make things work automatically, all of the `_git-$subcommand` functions need to be in separate files, which isn't happening; so `git-extras-completion.zsh` needs to be sourced manually. Putting it in `site-functions` would be misleading because it's not a function.
What I would do is
```rb
pkgshare.install "etc/git-extras-completion.zsh"
```
with a caveat
```rb
def caveats; <<-EOS.undent
To load Zsh completions, add the following to your .zshrc:
. #{HOMEBREW_PREFIX}/share/git-extras/git-extras-completion.zsh
EOS
end
```
By the way, this formula's `install` puts a bunch of shell scripts and man pages in place without any compilation, so I would switch to `bottle :unneeded` too.