Skip to main content
Deno 2 is finally here 🎉️
Learn more

chosts(1)

chosts(1) is a command to manage hosts file for macOS.

Install

deno install --allow-all --allow-write=/etc/hosts --allow-run --global https://deno.land/x/chosts@0.0.2/chosts.ts --force --import-map=https://deno.land/x/chosts@0.0.2/deno.jsonc

Usage

Configuration

Example

~/.config/chosts/chosts.yaml

version: 1
hosts: /etc/hosts
chosts: ./chosts

~/.config/chosts/chosts/default.yaml (default hosts file on macOS)

type: hosts
description: |-
  Host Database

  localhost is used to configure the loopback interface
  when the system is booting.  Do not change this entry.
entries:
  - ip: 127.0.0.1
    hostname: localhost
    description: IPv4 loopback
  - ip: 255.255.255.255.255
    hostname: broadcasthost
    description: Broadcast address for the local network segment
  - ip: ::1
    hostname: localhost
    description: IPv6 loopback

~/.config/chosts/chosts/sample.yaml

type: hosts
description: Sample Host Database
entries:
  - ip: 127.0.0.1
    hostname: sample.local
    description: Sample Host

~/.config/chosts/chosts/all.yaml

type: combined
description: All Hosts
settings:
  - default
  - sample

Types

hosts
combined

Commands

$ chosts list

List names of chosts.