

Command line tool for blocking sites to be more productive - feronull
https://github.com/feroc1ty/workmode

======
crazy_eye
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.

------
JoshMock
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.

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.

------
kaolinite
Nice project, though if you'd rather not install Node.JS and all of its
dependencies, you might want to try <https://github.com/leftnode/get-shit-
done>

There are a few versions of it in Python, PHP and sh so you can pick your
preference :-)

~~~
rjh29
My version, in Perl with Arch support:

<https://github.com/richardjharris/get-shit-done>

I've just realised I'll need to update it now Arch is using systemd...

------
IvarTJ

        var hostsFile = process.platform == "linux" ? "/etc/hosts/" : "C:\\Windows\\System32\\drivers\\etc\\hosts";
    

Surely this won't work on anything but Windows.

------
galenward
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.

What if instead of blocking sites, the nonproductive internet slowed down _a
lot_? 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.

------
Jonovono
Sweet. I am going to try this out!

Has anyone here used Self Control?
(<http://visitsteve.com/made/selfcontrol/>). 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?

~~~
timothya
I've used Self Control, and I like it in principle (it makes it difficult to
disable it after it's been turned on, which I like).

However, in practice it doesn't work too well for me. If you block youtube.com
or plus.google.com it tends to block other parts of Google (including Search
and Docs), which is a big dealbreaker. There's an Issue on Github for the bug,
but it's really old and there hasn't been any progress on it. If it worked as
it should, then I'd actually consider using Self Control.

~~~
Jonovono
Yeah, exactly. That's what I like about it too. Have you tried this one out?
If it solves those problems, it wouldn't be too hard to make it work like Self
Control. Maybe a GUI could be made for it. I am more familiar working in Node.

~~~
timothya
Well, this one doesn't seem to be working at the moment, it's giving me
errors, though I haven't spent much time trying to figure out what's going on.

I'd like to add preset block time to this one though, and / or make it harder
to disable.

------
valdiorn
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.

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)

~~~
rgbrgb
I think that time staring out the window is more important than the time
you're reading HN. That gap time when I'm just letting your mind work on stuff
"in the background" is when a lot of my best ideas bubble up. I think I saw a
talk about this or something but that's why they say you always get new ideas
in the shower.

------
axelav
if you're on a mac, Gas Mask is a really good tool to switch between different
/etc/hosts files

<http://www.clockwise.ee/gasmask/>

here's my 'focus mode'

<https://gist.github.com/2564478>

~~~
M4v3R
Also, try Self Control app: <http://selfcontrolapp.com> It has a black/white
list (depending on what you need) of hosts, and lets you set up a timer.

------
timothya
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>`:

    
    
        env: node\r: No such file or directory
    

(I'm on a Mac)

EDIT: Are you using Windows newlines? I think that's the problem.

------
arbeitandy
the proxy/pac file version of self-control:

    
    
      https://gist.github.com/3907633
    

[pac file in this gist is merely a demo, please clone it and add your sites-
to-blackhole-during-work]

the advantages of using a pac file over /etc/hosts are

* you can safely version control it

* you dont need to install extra software (at least on mac/windows)

* you can gist your determination

for more details of pac file, please dig into the reference link of pacfile:

    
    
      http://findproxyforurl.com/pac-functions/
    

there could be fun to use weekdayRange/timeRange to specify exact hours you
want to be away from any self-distraction.

------
darren
Concentrate does this with a nice interface (non-free, although with a very
long trial period): <http://getconcentrating.com/>

Unfortunately it doesn't seem to be well maintained.

------
amitagarwal
Here's a similar script written in VBS
[http://www.labnol.org/software/temporarily-block-
websites/18...](http://www.labnol.org/software/temporarily-block-
websites/18257/)

------
incision
Nice clean tool.

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.

~~~
brnstz
No one has infinite willpower. Making it a tad harder to browse reddit is a
useful deterrent. It makes you think twice. If you're trying to lose weight,
wearing a muzzle is extreme. However, it's a good idea to remove all the junk
food from your house. You can always buy more, but it's that much harder.

------
Supreme
Optimized version:

# turn on

sudo rm /etc/hosts

sudo ln -s /etc/hosts{.work,}

# turn off

sudo rm /etc/hosts

sudo ln -s /etc/hosts{.play,}

Optimized further (in your ~/.bashrc):

alias work="sudo rm /etc/hosts && sudo ln -s /etc/hosts{.work,}"

alias play="sudo rm /etc/hosts && sudo ln -s /etc/hosts{.play,}"

Optimization cubed (lets you define a base hosts file):

alias work="sudo rm /etc/hosts && sudo cat /etc/hosts.base >> /etc/hosts &&
sudo cat /etc/hosts.work >> /etc/hosts"

alias play=...

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.

~~~
pseudonym
This is close to what I have, except less complex. A single line in /etc/hosts
that redirects sites to 127.0.0.1, which gets commented or uncommented. The
fact that I have to go through the hassle of sudoing up and removing the
comment means I'm far more likely to catch myself before doing it and getting
back to work.

~~~
Supreme
Optimization #4:

alias play="sleep 120 && ..."

Two minutes should be enough for the craving to pass :-)

