Focus adds domains of your choice to /etc/hosts. It then blocks and unblocks them by uncommenting and commenting those domains.
Somewhere in your $PATH:
curl https://raw.githubusercontent.com/davejachimiak/focus/master/focus > focus
chmod +x ./focus
USAGE: focus <command> [<arg>]
COMMANDS:
focus activate Activate focus. This uncomments domains added to focus in /etc/hosts.
focus add <domain> Add <domain> to focus block in /etc/hosts.
focus deactivate De-activate focus. This comments-out added domains in /etc/hosts.
focus help Print this help text.
focus list List all domains that have been added to /etc/hosts through focus.
focus remove <domain> Remove <domain> from focus block in /etc/hosts.
focus status Tell whether focus is activated or de-activated.
Add facebook.com to focus block in /etc/hosts:
sudo focus add facebook.comRemove facebook.com from focus block:
sudo focus remove facebook.comList domains added with focus:
focus listRedirect added domains to 127.0.0.2
sudo focus activateStop redirecting added domains to 127.0.0.2:
sudo focus deactivate
Print whether focus is activated:
focus status
focus adds domains to /etc/hosts in a block surrounded by "#focus#" and "#eofocus". If focus is deactivated, adding domains will add them commented to /etc/hosts.
#focus#
#127.0.0.2 facebook.com
#eofocus#
Activating focus will uncomment the domains.
#focus#
127.0.0.2 facebook.com
#eofocus#
Adding domains while focus is activated will add them to the block uncommented.
#focus#
127.0.0.2 facebook.com
127.0.0.2 twitter.com
#eofocus#