Skip to content

croess/locate-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

locate-update

A modern, interactive wrapper for macOS's locate database updater with real-time stats, disk health monitoring, and a beautiful CLI interface.

macOS License

Why?

macOS includes a powerful locate command for finding files instantly, but its database only updates once per week (Saturdays at 3:15 AM). If you're actively developing, installing packages, or managing files, your searches return stale results.

Running the raw update command (sudo /usr/libexec/locate.updatedb) gives you zero feedback—just a blank terminal for 20-60 seconds.

locate-update solves both problems:

  • Update on demand whenever you need fresh results
  • See exactly what's happening with animated progress, stats, and health metrics

What?

╭────────────────────────────────────────────────────────────╮
│ 🔍 Locate Database Update                                  │
╰────────────────────────────────────────────────────────────╯

✦ Current State
╭────────────────────────────────────────────────────────────╮
│ Last indexed:  2025-11-20 14:59 (2h ago)                   │
│ Files indexed: 1,197,645                                   │
╰────────────────────────────────────────────────────────────╯

✦ Disk Health
╭────────────────────────────────────────────────────────────╮
│ Capacity: 1.8 TB                                           │
│ Used:     505.8 GB (27%)                                   │
│ Free:     1.3 TB (73%)                                     │
│ Status:   Healthy                                          │
│ SMART:    Verified                                         │
╰────────────────────────────────────────────────────────────╯

✦ Indexing
  Press n new files │ s dir sizes

⠹ Cataloging your Downloads folder chaos...       (12s)

Features

  • Real-time progress with animated spinner and elapsed time
  • Disk health dashboard showing capacity, usage, and SMART status
  • Delta tracking - see how many files changed since your last update
  • Interactive options during indexing:
    • Press n to see recently created files
    • Press s to see top directories by size
  • Beautiful CLI with box-drawing characters and color coding

Installation

Quick Install (recommended)

# Download the script
curl -fsSL https://raw.githubusercontent.com/YOUR_USERNAME/locate-update/main/locate-update -o /usr/local/bin/locate-update

# Make it executable
chmod +x /usr/local/bin/locate-update

Manual Install

# Clone the repository
git clone https://github.com/YOUR_USERNAME/locate-update.git
cd locate-update

# Copy to your PATH
cp locate-update /usr/local/bin/
chmod +x /usr/local/bin/locate-update

Alternative: Install to ~/.local/bin

If you prefer user-local installation:

# Create directory if needed
mkdir -p ~/.local/bin

# Copy script
cp locate-update ~/.local/bin/
chmod +x ~/.local/bin/locate-update

# Add to PATH (add this to your ~/.zshrc or ~/.bashrc)
export PATH="$HOME/.local/bin:$PATH"

Usage

Simply run:

locate-update

You'll be prompted for your password (required for sudo).

Interactive Commands

While indexing is running:

  • n - Show recently created files (since last index)
  • s - Show top 5 directories by disk usage

After Updating

Use the locate command to find files instantly:

# Find all Python files
locate .py

# Find a specific config file
locate nginx.conf

# Case-insensitive search
locate -i readme

Requirements

  • macOS (tested on Sonoma/Sequoia)
  • Bash 3.2+ (included with macOS)
  • Admin privileges (for sudo)

How It Works

  1. Authenticates with sudo upfront (no password prompt during animation)
  2. Shows current index state and disk health
  3. Runs /usr/libexec/locate.updatedb in background
  4. Displays animated progress with rotating messages
  5. Tracks file count delta between runs (stored in ~/.cache/locate-update-stats)
  6. Reports results with new totals

Technical Details

  • Database location: /var/db/locate.database
  • macOS default update schedule: Weekly via /etc/periodic/weekly/310.locate
  • Typical index time: 15-45 seconds depending on disk size and file count

License

MIT License - see LICENSE for details.

Contributing

Contributions welcome! Feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests

Credits

Built with caffeine and the desire to never stare at a blank terminal again.

About

Modern macOS locate database updater with interactive CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages