1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-12-28 20:12:42 +00:00
Go to file
William Melody 187222614a Use braces in all variable references.
Braces are only required in certain cases, but the cognitive overhead in
keeping track of which cases require braces can be reduced by simply
always using them.

Example: `${NAME}`

Retain more widely-used braces `$NAME` convention in documentation.
2016-02-23 18:14:21 -08:00
test Use braces in all variable references. 2016-02-23 18:14:21 -08:00
hosts Use braces in all variable references. 2016-02-23 18:14:21 -08:00
LICENSE Add license 2015-03-18 18:39:22 -07:00
Makefile Add basic Makefile 2015-05-20 16:46:02 -07:00
package.json Bump version to 2.1.5. 2016-01-26 20:42:26 -08:00
Readme.md Update help/usage formatting. 2016-01-26 20:25:16 -08:00

    __               __
   / /_  ____  _____/ /______
  / __ \/ __ \/ ___/ __/ ___/
 / / / / /_/ (__  ) /_(__  )
/_/ /_/\____/____/\__/____/

Hosts

A command line program for managing hosts file entries.

Installation

Homebrew

To install with Homebrew:

brew tap alphabetum/taps && brew install alphabetum/taps/hosts

bpkg

To install with bpkg:

bpkg install alphabetum/hosts

Manual

To install manually, simply add the hosts script to your $PATH. If you already have a ~/bin directory, you can use the following command:

curl -L https://raw.github.com/alphabetum/hosts/master/hosts \
  -o ~/bin/hosts && chmod +x ~/bin/hosts

Usage

Usage:
  hosts
  hosts add <ip> <hostname> [<comment>]
  hosts disable (<ip> | <hostname> | <search string>)
  hosts disabled
  hosts edit
  hosts enable (<ip> | <hostname> | <search string>)
  hosts enabled
  hosts file
  hosts list [enabled | disabled | <search string>]
  hosts show (<ip> | <hostname> | <search string>)
  hosts remove (<ip> | <hostname> | <search string>) [--force]

For full usage, run:

hosts help

For help with a particular command, try:

hosts help <command name>

Commands

hosts add <ip> <hostname> [<comment>]

Add a given IP address and hostname pair, along with an optional comment.

hosts remove (<ip> | <hostname> | <search string>) [--force]

Remove one or more records based on a given IP address, hostname, or search string. When the --force option is used, the confirmation prompt is supressed.

hosts list [enabled | disabled | <search string>]

List the existing IP / hostname pairs, optionally limited to a specified state. When provided with a seach string, all matching enabled records will be printed.

hosts show (<ip> | <hostname> | <search string>)

Print entries matching a given IP address, hostname, or search string.

hosts disable (<ip> | <hostname> | <search string>)

Disable one or more records based on a given ip address, hostname, or search string.

hosts disabled

List all disabled records. This is an alias for hosts list disabled.

hosts enable (<ip> | <hostname> | <search string>)

Enable one or more disabled records based on a given ip address, hostname, or search string.

hosts enabled

List all enabled records. This is an alias for hosts list enabled.

hosts edit

Open the hosts file (/etc/hosts) file in your editor.

hosts file

Print the entire contents of the /etc/hosts file.

Why

Although it's easy to just edit the hosts file manually, it's nice to have a structured way to edit it and keep things a little organized.

Acknowledgements

Based on prior work by:

Original idea and interface (since changed) via:

https://github.com/macmade/host-manager