CLI Tool

Manage Hosts CLI

A safe macOS hosts file CLI with backup/restore, URL normalization, and interactive domain removal.

Features

Backup & Restore

Automatic backups before every change with easy restore functionality.

URL Normalization

Accepts plain domains or full URLs, automatically extracts the domain.

Interactive Removal

Numbered picker interface for selecting and removing blocked domains.

Installation

Homebrew (recommended)

Terminal
brew tap ai-armageddon/manage-hosts-cli
brew install manage-hosts-cli

Direct install script

Terminal
./install.sh

Use --user flag for user-only install (no sudo required)

Usage

First-time setup

Terminal
sudo blocked-sites init --migrate-existing

List blocked domains

Terminal
sudo blocked-sites list

Add domains

Terminal
sudo blocked-sites add instagram.com g2a.com
sudo blocked-sites add 'https://reddit.com/r/all'

Remove domains

Terminal
sudo blocked-sites remove instagram.com
sudo blocked-sites remove

Run without arguments for interactive removal mode

Backup & restore

Terminal
sudo blocked-sites backups
sudo blocked-sites restore ./backups/hosts.YYYYMMDD-HHMMSS-ffffff.bak

Privacy & Safety

  • No API keys, tokens, or passwords in the code
  • Does not send data over the network
  • Backup files are ignored by default