Skip to content

Instantly share code, notes, and snippets.

@umbrae
Created January 17, 2012 14:03
Show Gist options
  • Select an option

  • Save umbrae/1626720 to your computer and use it in GitHub Desktop.

Select an option

Save umbrae/1626720 to your computer and use it in GitHub Desktop.
gotime
# Step 1. Put some commented-out entries in your /etc/hosts file for sites you
# want to block while you're working, with a comment/hashtag of gotime, like
# this:
#127.0.0.1 reddit.com #gotime
#127.0.0.1 www.facebook.com #gotime
# Step 2. Add these lines to your shell's rc file:
alias gotime="sudo perl -pi -e 's/#([^\n]+)#gotime/\$1#gotime/g' /etc/hosts"
alias timetogo="sudo perl -pi -e 's/([^\n]+)#gotime/#\$1#gotime/g' /etc/hosts"
# Step 3. Re-source your rc file, or start a new shell
source .bashrc
# Step 4. When you want to get work done, use "gotime" to block those sites
# you specified above. Use "timetogo" to unblock them. You'll probably need to
# enter your password.
gotime
# Step 5. Be more productive! After unblocking a site, you may need to flush
# your DNS cache. In OS X, that's 'dscacheutil -flushcache'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment