Derive service completions from Cellar paths #24009

Merged
p-linnane opened 7:48pm on September 16, 2026 wanted to merge 113 Ξ” into homebrew/brew main from
service-completions
Reviewing
6 fewer changed lines
(12% less) vs GitHub
This saves about 21.0 hours per year vs conventional diff tools
p-linnane and 1 other authored
of work during September 16
Diff Delta:
113
About 20 Diff Delta/hour
Classified as:  General

p-linnane's Description of Work #24006 Derive service completions from Cellar paths

brew services tab completion extracted the service name with awk -F'homebrew.|.service' '{print $3}'. That regex only worked for the legacy homebrew.<name> files under /opt/homebrew, where the prefix supplied the extra match. It completes nothing for the current sh.brew.<name> files, for custom service names, and for any prefix without homebrew in its path such as /usr/local or Linuxbrew.

The Bash, fish and zsh completers now take the formula name from the Cellar directory ($(NF-2) of the path) and deduplicate with sort -u, so multiple installed versions of a formula produce one entry. The generated completions are regenerated from the templates.

To reproduce: brew install postgresql@18, then brew services start and press tab. Nothing is completed before this change.

Fixes #24006



  • [x] Have you followed our Contributing guidelines?

  • [x] Have you checked for other open Pull Requests for the same change?

  • [x] Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.

  • [x] Have you explained why you'd like these changes included, not just what they do?

  • [x] For bug fixes, have you given step-by-step brew commands to reproduce the bug?

  • [x] Have you written new tests (excluding integration tests)? Here's an example.

  • [x] Have you successfully run brew lgtm (style, typechecking and tests) locally?



  • [x] I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code (Fable 5.1) drafted the implementation and tests; I reviewed the diff, verified the new test fails without the fix and passes with it, and ran brew lgtm --online plus targeted specs.


7 total changed files
(1 file ignored)
Loading changes...
Loading changes...
Loading changes...
Loading changes...
Loading changes...
Congrats, you've cleared the final file
LGTM-land is officially in view