Skip to content

Getting Started

Get up and running with txeh in under 5 minutes.

Install the CLI

brew install txn2/tap/txeh
go install github.com/txn2/txeh/txeh@latest

Download the latest release from GitHub Releases for your platform.

Your First Commands

Add a hostname:

sudo txeh add 127.0.0.1 myapp.local

List hosts for an IP:

txeh list ip 127.0.0.1

Remove a hostname:

sudo txeh remove host myapp.local

Preview changes without saving (dry run):

sudo txeh add 127.0.0.1 myapp.local --dryrun

Use as a Go Library

Add the dependency:

go get github.com/txn2/txeh

Basic usage:

package main

import (
    "fmt"
    "github.com/txn2/txeh"
)

func main() {
    hosts, err := txeh.NewHostsDefault()
    if err != nil {
        panic(err)
    }

    hosts.AddHost("127.0.0.1", "myapp.local")
    fmt.Println(hosts.RenderHostsFile())

    err = hosts.Save()
    if err != nil {
        panic(err)
    }
}

Next Steps