hosts, a python with textual based /etc/hosts editor.
Find a file
2026-09-04 18:40:57 +02:00
docs Add TUI design guide and update contributing documentation 2026-09-04 16:44:21 +02:00
images Add user interface screenshot to documentation 2025-08-18 16:04:32 +02:00
src/hosts Refine entry search and field ordering 2026-09-04 18:40:57 +02:00
tests Migrate TUI to design guide 2026-09-04 18:31:25 +02:00
.gitignore Add .gitignore file to exclude unnecessary files and directories 2025-07-29 15:09:57 +02:00
.python-version initial commit 2025-07-29 13:50:55 +02:00
AGENTS.md Add TUI design guide and update contributing documentation 2026-09-04 16:44:21 +02:00
CONTEXT.md Refactor test cases for improved readability and consistency 2026-09-03 12:47:11 +02:00
CONTRIBUTING.md Add TUI design guide and update contributing documentation 2026-09-04 16:44:21 +02:00
favicon.svg Refactor test cases for improved readability and consistency 2026-09-03 12:47:11 +02:00
LICENSE Refactor test cases for improved readability and consistency 2026-09-03 12:47:11 +02:00
mise.lock Adopt mise for development workflows 2026-09-04 14:39:02 +02:00
mise.toml Adopt mise for development workflows 2026-09-04 14:39:02 +02:00
pyproject.toml Adopt mise for development workflows 2026-09-04 14:39:02 +02:00
README.md Fix #6: Make advanced filtering reachable from the TUI 2026-09-04 14:51:59 +02:00
uv.lock Fix preset selection and update Textual dependencies 2026-09-04 15:00:41 +02:00

hosts

A keyboard-first terminal application for inspecting and editing /etc/hosts on macOS and Linux.

Warning

hosts is alpha software. It can replace a system file using sudo, and several recovery and persistence workflows still have known limitations. Read the user guide before entering Privileged Mode.

The hosts terminal interface

What it does

  • Browses, searches, and sorts active and inactive Host Entries.
  • Filters Host Entries by status, entry type, DNS resolution state, and search fields.
  • Hides or shows protected localhost and broadcasthost Default Entries.
  • Adds, edits, deletes, activates, deactivates, and reorders Host Entries.
  • Creates DNS Entries and manually refreshes their resolved IP addresses.
  • Gates every /etc/hosts mutation behind an explicit Privileged Mode.
  • Creates a timestamped Pre-edit Backup before Privileged Mode begins.
  • Supports undo and redo during the current Privileged Mode session.

The application starts in Read-only Mode. Default Entries cannot be edited, deleted, activated, deactivated, or moved.

Requirements

  • macOS or Linux with /etc/hosts and sudo
  • Python 3.13 or newer
  • uv

The project is designed for macOS and Linux, but does not yet publish a tested platform matrix.

Run

The normal user entry point runs the current revision from the canonical Forgejo repository:

uvx git+https://git.s1q.dev/phg/hosts.git

Caution

This command follows the repository's default branch because the project does not yet publish versioned releases. Review the current project state and known limitations before granting sudo access.

Press Ctrl+E to enter Privileged Mode. The application uses an existing sudo authorization or temporarily returns control of the terminal to sudo and its configured PAM authentication method. It then creates a Pre-edit Backup before enabling changes. hosts never collects or handles authentication credentials.

Start with the user guide for the complete workflow, including persistence behavior and manual recovery.

Essential keys

Key Action
Up / Down Select a Host Entry
Ctrl+E Enter or leave Privileged Mode
n Add a Host Entry
e Open the selected Host Entry in the Entry Editor
d Delete the selected Host Entry
Space Activate or deactivate the selected Host Entry
Ctrl+S Save the current in-memory state
Ctrl+F Open advanced filters
? Show help
q or Ctrl+C Quit

Mutating keys work only in Privileged Mode. See the complete key reference for navigation, sorting, DNS refresh, movement, undo, and redo.

Safety and known limitations

  • Reloading discards unsaved in-memory state.
  • Pre-edit Backups are not listed or restored by the TUI and have no retention management. Manual recovery is documented in the user guide.
  • Leaving Privileged Mode clears the application's session state but does not alter the user's cached sudo timestamp.
  • Serialization preserves Host Entries and comments semantically, but normalizes spacing, comment placement, and blank lines. It is not a byte-for-byte round trip.

Read Persistence and recovery before making system-file changes.

Develop and contribute

Clone the repository for development:

git clone https://git.s1q.dev/phg/hosts.git
cd hosts
mise install
mise run sync
mise run app

mise installs the locked Python and uv versions and provides the project's development tasks.

See CONTRIBUTING.md for code boundaries, safety contracts, tests, linting, and documentation expectations. Domain language lives in CONTEXT.md, and consequential design decisions live in docs/adr/.

Report bugs and request features in the Forgejo issue tracker.

License

Licensed under the MIT License.