feat: Profile management (named groups with enable/disable)
@cjimti is already working on this.
Since Feb 8, 2026.
Assessment
This issue has not been assessed yet.
Description
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from txn2/txeh
-
feat: GitHub Action for CI/CD hosts file setupMay be free again @cjimti claimed this 267 days ago, and no pull request is open. Openenhancement
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
limitlessprojects/Go-Hybrid#3342 ·
Maintainers usually reply within 1 day
-
status/ready type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
buildpacks/pack#2733 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
kind/bug needs-priority needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
konveyor/tackle2-hub#1166 · 1 comment ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
router-for-me/CLIProxyAPI#7209 ·
Maintainers usually reply within 1 day