hosts/README.md

128 lines
2.9 KiB
Markdown
Raw Normal View History

2015-05-21 03:31:05 +00:00
__ __
/ /_ ____ _____/ /______
/ __ \/ __ \/ ___/ __/ ___/
/ / / / /_/ (__ ) /_(__ )
/_/ /_/\____/____/\__/____/
# Hosts
2015-11-25 00:16:09 +00:00
A command line program for managing hosts file entries.
## Installation
### Homebrew
To install with [Homebrew](http://brew.sh/):
2015-11-25 00:15:45 +00:00
```bash
brew tap alphabetum/taps && brew install alphabetum/taps/hosts
```
### bpkg
To install with [bpkg](http://www.bpkg.io/):
2015-11-25 00:15:45 +00:00
```bash
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:
2015-11-25 00:15:45 +00:00
```bash
curl -L https://raw.github.com/alphabetum/hosts/master/hosts \
-o ~/bin/hosts && chmod +x ~/bin/hosts
```
## Usage
2015-11-25 00:15:45 +00:00
```text
Usage:
hosts
2016-01-27 04:25:16 +00:00
hosts add <ip> <hostname> [<comment>]
hosts disable (<ip> | <hostname> | <search string>)
2015-11-25 00:15:45 +00:00
hosts disabled
hosts edit
2016-01-27 04:25:16 +00:00
hosts enable (<ip> | <hostname> | <search string>)
2015-11-25 00:15:45 +00:00
hosts enabled
hosts file
hosts list [enabled | disabled | <search string>]
2016-01-27 04:25:16 +00:00
hosts show (<ip> | <hostname> | <search string>)
hosts remove (<ip> | <hostname> | <search string>) [--force]
2015-11-25 00:15:45 +00:00
```
2015-03-17 03:13:19 +00:00
For full usage, run:
2015-11-25 00:15:45 +00:00
```text
hosts help
```
2015-03-17 03:13:19 +00:00
2015-03-19 01:23:59 +00:00
For help with a particular command, try:
2015-03-17 03:13:19 +00:00
2015-11-25 00:15:45 +00:00
```text
hosts help <command name>
```
2015-03-17 03:13:19 +00:00
2015-03-19 21:43:32 +00:00
## Commands
2016-01-27 04:25:16 +00:00
###### `hosts add <ip> <hostname> [<comment>]`
2015-03-19 21:43:32 +00:00
Add a given IP address and hostname pair, along with an optional comment.
2015-03-19 21:43:32 +00:00
2016-01-27 04:25:16 +00:00
###### `hosts remove (<ip> | <hostname> | <search string>) [--force]`
2015-03-19 21:43:32 +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.
2016-01-27 04:25:16 +00:00
###### `hosts show (<ip> | <hostname> | <search string>)`
2015-03-19 21:43:32 +00:00
Print entries matching a given IP address, hostname, or search string.
2016-01-27 04:25:16 +00:00
###### `hosts disable (<ip> | <hostname> | <search string>)`
2015-03-19 21:43:32 +00:00
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`.
2016-01-27 04:25:16 +00:00
###### `hosts enable (<ip> | <hostname> | <search string>)`
2015-03-19 21:43:32 +00:00
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`.
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.
## 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