This repository contains two related projects for managing and querying Homebrew package installations:
brew-tools/- The source repository containing the Python toolshomebrew-brew-tools/- The Homebrew tap repository for installing viabrew
Indexes all Homebrew packages (formulae and casks) installed on your system and creates a persistent JSON index (installs_index.json) in your Homebrew repository. The index tracks:
- Package names and versions
- Installation paths
- First installation dates
- Optional GitHub commit history enrichment
Queries the index created by brew-index to find packages that were first installed within a specific time window.
-
Clone this repository:
git clone https://github.com/newalexandria/homebrew-brew-tools.git cd homebrew-brew-tools -
Run the setup script:
cd brew-tools ./scripts/setup.shThis installs the executables to
~/.local/bin/. Make sure~/.local/binis in yourPATH:echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc # or ~/.bashrc source ~/.zshrc
Or manually copy the executables:
mkdir -p ~/.local/bin cp brew-tools/bin/* ~/.local/bin/ chmod +x ~/.local/bin/brew-index ~/.local/bin/brew-first-installs
Once the tap is published to GitHub, you can install via Homebrew:
brew tap newalexandria/brew-tools
brew install newalexandria/brew-tools/brew-index
brew install newalexandria/brew-tools/brew-first-installsFirst, run brew-index to scan your Homebrew installations and create the index:
brew-indexThis creates installs_index.json in your Homebrew repository (typically $(brew --repository)/installs_index.json).
Optional: Enrich with GitHub History
If you have the GitHub CLI (gh) installed and authenticated, you can enrich the index with repository commit dates:
brew-index --enrichThis queries GitHub to find when each formula was first added to its tap repository. Note: This can take a while as it makes API calls for each package.
Optional: Include Available Packages
To also index packages that are available but not currently installed (added in the last year):
brew-index --availableYou can combine flags:
brew-index --enrich --availableUse brew-first-installs to find packages installed within a time window:
# Find packages first installed between 30 and 7 days ago
brew-first-installs 30 7
# Find packages first installed in the last 7 days
brew-first-installs 7 0
# Output as JSON
brew-first-installs 30 7 --json
# Show detailed brew info for each match
brew-first-installs 30 7 --infoArguments:
X- Older bound (days ago)Y- Newer bound (days ago)--json- Output raw JSON array instead of formatted table--info- Showbrew infooutput for each matching package
-
Create an index:
brew-index
Expected: Creates
installs_index.jsonin your Homebrew repository. Check with:ls -la $(brew --repository)/installs_index.json -
Query recent installs:
brew-first-installs 365 0
Expected: Shows a table of packages first installed in the last year.
-
Test JSON output:
brew-first-installs 30 0 --json | jq .
Expected: JSON array of matching packages.
Both tools support --help:
brew-index --help
brew-first-installs --helpIf you have gh installed:
brew-index --enrichExpected: Progress messages showing GitHub API calls and enrichment results.
Check that both tools are available:
which brew-index
which brew-first-installsBoth should point to ~/.local/bin/ (for local install) or /opt/homebrew/bin/ (for tap install).
homebrew-brew-tools/
├── brew-tools/ # Source repository
│ ├── bin/ # Executable scripts
│ │ ├── brew-index
│ │ └── brew-first-installs
│ ├── scripts/ # Setup scripts
│ ├── .github/workflows/ # CI/CD workflows
│ └── README.md # Tool-specific documentation
│
├── homebrew-brew-tools/ # Homebrew tap repository
│ └── Formula/ # Homebrew formula definitions
│ ├── brew-index.rb
│ └── brew-first-installs.rb
│
└── README.md # This file
- Python 3.11+ - Both tools are Python scripts
- Homebrew - Required for package management
- GitHub CLI (
gh) - Optional, for enrichment feature - macOS - Homebrew is primarily for macOS (though Linux support exists)
If brew-first-installs reports the index file is missing, run brew-index first to create it.
Ensure the executables have execute permissions:
chmod +x ~/.local/bin/brew-index ~/.local/bin/brew-first-installsMake sure ~/.local/bin is in your PATH. Add to your shell config:
export PATH="$HOME/.local/bin:$PATH"If --enrich fails, ensure:
ghis installed:brew install gh- You're authenticated:
gh auth status - You have internet connectivity
This repository contains both the tool source code and the Homebrew tap definitions. When making changes:
- Update the tools in
brew-tools/bin/ - Update the version in
brew-tools/VERSIONif needed - Update the Formula files in
homebrew-brew-tools/Formula/if installation changes are needed - Test locally before pushing
MIT License - See brew-tools/LICENSE for details.