Similar to others here but I thought I'd share my way as well (on OSX here, but would work on other Unixes):<p>Throw these somewhere in your profile:<p>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'<p>Then fill /etc/hosts.zonemode with the sites you want to block:<p>127.0.0.1 news.ycombinator.com<p>127.0.0.1 www.reddit.com<p>Then make sure your user can run passwordless sudo on those commands and you are set.
I prefer the /etc/hosts hack, putting in entries like `127.0.0.1 twitter.com`. That way, when I actually want to visit Twitter, I have to `sudo vim /etc/hosts`, enter my password, comment out the host entry, save, go to Twitter, and then uncomment the entry, save and quit when I'm ready to block it again.<p>The inconvenience of the action is what makes it work. If I only had to type `workmode stop` I'd have that committed to muscle memory by the end of a work day or two.
Nice project, though if you'd rather not install Node.JS and all of its dependencies, you might want to try <a href="https://github.com/leftnode/get-shit-done" rel="nofollow">https://github.com/leftnode/get-shit-done</a><p>There are a few versions of it in Python, PHP and sh so you can pick your preference :-)
<p><pre><code> var hostsFile = process.platform == "linux" ? "/etc/hosts/" : "C:\\Windows\\System32\\drivers\\etc\\hosts";
</code></pre>
Surely this won't work on anything but Windows.
Here's the thing with this: It's easy to find new unproductive sites and an outright ban from distractions is difficult to live with - humans crave distraction.<p>What if instead of blocking sites, the nonproductive internet slowed down <i>a lot</i>? Then in the 10 seconds you waited for Hacker News to load, you might think to yourself that this is a bad idea and give up.
Sweet. I am going to try this out!<p>Has anyone here used Self Control? (<a href="http://visitsteve.com/made/selfcontrol/" rel="nofollow">http://visitsteve.com/made/selfcontrol/</a>). Sometimes when I block websites, like Reddit.com and this one and few others it makes other websites look weird. Like the page will still load but be broken. I think Self Control is blocking sites the same way this does. Any idea why this happens?
For me, procrastination is a normal part of my routine. I've tried forcing myself not to do it, but you know what happens? Instead of reading hacker news, I just stare out the window for ten minutes, or think about what exercises I'm going to do at the gym.<p>Your mind is not willing to do the task you need it to do and there is nothing you can do about it. (that's my experience)
if you're on a mac, Gas Mask is a really good tool to switch between different /etc/hosts files<p><a href="http://www.clockwise.ee/gasmask/" rel="nofollow">http://www.clockwise.ee/gasmask/</a><p>here's my 'focus mode'<p><a href="https://gist.github.com/2564478" rel="nofollow">https://gist.github.com/2564478</a>
It doesn't seem to work for me. After installing as per the instructions, I get the following error whenever I try to do `workmode <x>`:<p><pre><code> env: node\r: No such file or directory
</code></pre>
(I'm on a Mac)<p>EDIT: Are you using Windows newlines? I think that's the problem.
the proxy/pac file version of self-control:<p><pre><code> https://gist.github.com/3907633
</code></pre>
[pac file in this gist is merely a demo, please clone it and add your sites-to-blackhole-during-work]<p>the advantages of using a pac file over /etc/hosts are<p>* you can safely version control it<p>* you dont need to install extra software (at least on mac/windows)<p>* you can gist your determination<p>for more details of pac file, please dig into the reference link of pacfile:<p><pre><code> http://findproxyforurl.com/pac-functions/
</code></pre>
there could be fun to use weekdayRange/timeRange to specify exact hours you want to be away from any self-distraction.
Concentrate does this with a nice interface (non-free, although with a very long trial period): <a href="http://getconcentrating.com/" rel="nofollow">http://getconcentrating.com/</a><p>Unfortunately it doesn't seem to be well maintained.
Here's a similar script written in VBS <a href="http://www.labnol.org/software/temporarily-block-websites/18257/" rel="nofollow">http://www.labnol.org/software/temporarily-block-websites/18...</a>
Nice clean tool.<p>Thing is, I'd like these tools to wearing muzzle to lose weight. It's misdirection of effort into avoiding rather than addressing the demonstrated issue of self-control.
Optimized version:<p># turn on<p>sudo rm /etc/hosts<p>sudo ln -s /etc/hosts{.work,}<p># turn off<p>sudo rm /etc/hosts<p>sudo ln -s /etc/hosts{.play,}<p>Optimized further (in your ~/.bashrc):<p>alias work="sudo rm /etc/hosts && sudo ln -s /etc/hosts{.work,}"<p>alias play="sudo rm /etc/hosts && sudo ln -s /etc/hosts{.play,}"<p>Optimization cubed (lets you define a base hosts file):<p>alias work="sudo rm /etc/hosts && sudo cat /etc/hosts.base >> /etc/hosts && sudo cat /etc/hosts.work >> /etc/hosts"<p>alias play=...<p>The number of upvotes, the fact that you thought this was necessary and the fact that this application exists all made me facepalm hard. I can't even see right now.