2015-03-17 00:05:46 +00:00
|
|
|
# Hosts
|
|
|
|
|
2015-03-17 03:13:19 +00:00
|
|
|
A command line program with shortcuts for managing hosts file entries.
|
2015-03-17 00:05:46 +00:00
|
|
|
|
2015-03-19 01:35:45 +00:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
To get started, add the `hosts` script to your path.
|
|
|
|
|
|
|
|
### Homebrew
|
|
|
|
|
|
|
|
To install with homebrew, use the following command:
|
|
|
|
|
|
|
|
brew install alphabetum/taps/hosts
|
|
|
|
|
2015-03-17 00:05:46 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage:
|
2015-03-19 01:19:52 +00:00
|
|
|
hosts
|
2015-03-21 01:06:00 +00:00
|
|
|
hosts add <ip> <hostname> [comment]
|
2015-03-19 01:22:37 +00:00
|
|
|
hosts remove ( <ip> | <hostname> | <search string> ) [--force]
|
2015-03-19 00:04:39 +00:00
|
|
|
hosts list [enabled | disabled | <search string>]
|
2015-03-18 23:07:49 +00:00
|
|
|
hosts show ( <ip> | <hostname> | <search string> )
|
2015-03-19 01:22:37 +00:00
|
|
|
hosts disable ( <ip> | <hostname> | <search string> )
|
2015-03-20 23:44:43 +00:00
|
|
|
hosts disabled
|
2015-03-19 01:22:37 +00:00
|
|
|
hosts enable ( <ip> | <hostname> | <search string> )
|
2015-03-20 23:44:43 +00:00
|
|
|
hosts enabled
|
2015-03-17 00:38:06 +00:00
|
|
|
hosts edit
|
2015-03-17 02:56:16 +00:00
|
|
|
hosts file
|
2015-03-17 00:19:17 +00:00
|
|
|
|
2015-03-17 03:13:19 +00:00
|
|
|
For full usage, run:
|
|
|
|
|
|
|
|
hosts help
|
|
|
|
|
2015-03-19 01:23:59 +00:00
|
|
|
For help with a particular command, try:
|
2015-03-17 03:13:19 +00:00
|
|
|
|
|
|
|
hosts help <command name>
|
|
|
|
|
2015-03-19 21:43:32 +00:00
|
|
|
## Commands
|
|
|
|
|
2015-03-21 01:06:00 +00:00
|
|
|
###### `hosts add <ip> <hostname> [comment]`
|
2015-03-19 21:43:32 +00:00
|
|
|
|
2015-03-21 01:06:00 +00:00
|
|
|
Add a given IP address and hostname pair, along with an optional comment.
|
2015-03-19 21:43:32 +00:00
|
|
|
|
|
|
|
###### `hosts remove ( <ip> | <hostname> | <search string> ) [--force]`
|
|
|
|
|
2015-03-20 00:14:04 +00:00
|
|
|
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.
|
2015-03-19 21:43:32 +00:00
|
|
|
|
|
|
|
###### `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.
|
|
|
|
|
2015-03-20 23:44:43 +00:00
|
|
|
###### `hosts disabled`
|
|
|
|
|
|
|
|
List all disabled records. This is an alias for `hosts list disabled`.
|
|
|
|
|
2015-03-19 21:43:32 +00:00
|
|
|
###### `hosts enable ( <ip> | <hostname> | <search string> )`
|
|
|
|
|
|
|
|
Enable one or more disabled records based on a given ip address, hostname,
|
|
|
|
or search string.
|
|
|
|
|
2015-03-20 23:44:43 +00:00
|
|
|
###### `hosts enabled`
|
|
|
|
|
|
|
|
List all enabled records. This is an alias for `hosts list enabled`.
|
|
|
|
|
2015-03-19 21:43:32 +00:00
|
|
|
###### `hosts edit`
|
|
|
|
|
|
|
|
Open the hosts file (/etc/hosts) file in your editor.
|
|
|
|
|
|
|
|
###### `hosts file`
|
|
|
|
|
|
|
|
Print the entire contents of the /etc/hosts file.
|
|
|
|
|
2015-03-19 01:44:06 +00:00
|
|
|
## 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.
|
|
|
|
|
2015-03-17 00:19:17 +00:00
|
|
|
## Acknowledgements
|
|
|
|
|
|
|
|
Based on prior work by:
|
|
|
|
|
|
|
|
- https://github.com/nddrylliog
|
|
|
|
- https://gist.github.com/nddrylliog/1368532
|
|
|
|
- https://github.com/dfeyer
|
|
|
|
- https://gist.github.com/dfeyer/1369760
|
|
|
|
|
|
|
|
Original idea and interface (since changed) via:
|
|
|
|
|
|
|
|
https://github.com/macmade/host-manager
|