feat: Profile management (named groups with enable/disable)

Open
#44 0 comments 0 reactions 1 assignee View on GitHub

@cjimti is already working on this.

Since Feb 8, 2026.

Assessment

This issue has not been assessed yet.

Description

enhancement
Problem

If you work with multiple environments you end up with blocks of hosts entries that you comment and uncomment by hand. hostctl has profile management for this, but only as a CLI with no library API.

txeh already has AddHostWithComment and RemoveByComment, which track where entries came from. Profiles can build on that.

Proposed solution

Tag entries with [profile:name] in a comment. Enabled entries are active lines; disabled entries are comment-prefixed. The hosts file stays readable and editable by hand.

10.0.0.1  myservice.local  # [profile:dev]
# [profile:staging] 10.1.0.1  myservice.local

CLI:

txeh profile add dev 10.0.0.1 myservice.local
txeh profile enable dev
txeh profile disable dev       # comments out, doesn't delete
txeh profile list
txeh profile show dev
txeh profile remove staging
txeh profile export dev > dev.json
txeh profile import < team.json

Library:

hosts.AddProfile("dev", []ProfileEntry{
    {IP: "10.0.0.1", Hosts: []string{"myservice.local"}},
})
hosts.EnableProfile("dev")
hosts.DisableProfile("staging")
hosts.ListProfiles()        // []string
hosts.ProfileEntries("dev") // []ProfileEntry
hosts.RemoveProfile("dev")
hosts.ExportProfile("dev")  // []byte (JSON)
hosts.ImportProfile(data)

Enabling a profile doesn't disable others. Entries without a profile tag are left alone. All operations go through the existing mutex.

Alternatives considered

Separate file per profile: you lose the single-file view when editing /etc/hosts by hand, and merging adds complexity.

Sidecar state file (SQLite, JSON): the hosts file should be the source of truth. Comment tags keep everything in one place with no extra dependencies.

Dominant language
Go
Stars
342
Forks
42
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from txn2/txeh

All issues in txn2/txeh

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.