Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cheesy script to encourage productivity by blocking time sinks at the DNS level
#!/bin/bash
function usage {
echo "Usage: distractions [on/off]"
exit
}
if [ $# -eq 0 ]; then
usage
fi
if [ $1 = "off" ]; then
sudo sed -i '/^#-d-/,/^#-d-/ { /^#-d-/b; s/^# // }' /etc/hosts
elif [ $1 = "on" ]; then
sudo sed -i '/^#-d-/,/^#-d-/ { /^#-d-/b; s/^/# / }' /etc/hosts
else
usage
fi
127.0.1.1 mymachine
#-d- Productivity mode blacklist
# 0.0.0.0 reddit.com
# 0.0.0.0 www.reddit.com
# 0.0.0.0 news.ycombinator.com
# 0.0.0.0 facebook.com
# 0.0.0.0 www.facebook.com
# 0.0.0.0 twitter.com
# 0.0.0.0 www.twitter.com
# 0.0.0.0 reader.google.com
# 0.0.0.0 minecraft.net
# 0.0.0.0 www.minecraft.net
# 0.0.0.0 minecraftforum.net
# 0.0.0.0 www.minecraftforum.net
#-d- End productivity mode blacklist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment