Hacker News new | ask | show | jobs
by crazy_eye 4988 days ago
Similar to others here but I thought I'd share my way as well (on OSX here, but would work on other Unixes):

Throw these somewhere in your profile:

alias zonemode='sudo mv /etc/hosts /etc/hosts.zoneback && sudo mv /etc/hosts.zonemode /etc/hosts && dscacheutil -flushcache' alias zoneoff='sudo mv /etc/hosts /etc/hosts.zonemode && sudo mv /etc/hosts.zoneback /etc/hosts && dscacheutil -flushcache'

Then fill /etc/hosts.zonemode with the sites you want to block:

127.0.0.1 news.ycombinator.com

127.0.0.1 www.reddit.com

Then make sure your user can run passwordless sudo on those commands and you are set.