Skip to content

Instantly share code, notes, and snippets.

@DavidToca
Forked from afgomez/lets.sh
Created March 16, 2012 16:43
Show Gist options
  • Save DavidToca/2051027 to your computer and use it in GitHub Desktop.
Save DavidToca/2051027 to your computer and use it in GitHub Desktop.
Simple productivity booster
#!/bin/bash
# lets. A productivity booster
# based on ideas from https://gist.github.com/605292
#
# Copy your /etc/hosts to /etc/hosts.play and create a new one called /etc/hosts.work with a list of blocked sites
# Usage: sudo lets [play|work]
if [ $# = 0 ]
then
echo "Don't know what I must do!" >&2
exit 1
fi
if [ $UID -ne 0 ]
then
echo "Use me with sudo!" >&2
exit 2
fi
HOSTS=/etc/hosts
ORIGIN="$HOSTS.$1"
if [ -e $ORIGIN ]
then # Let's do something!!
FLUSH="$(which dscacheutil) -flushcache"
rm $HOSTS && cp $ORIGIN $HOSTS && echo "Let's $1!"
$FLUSH
else
echo "Ooops, don't know how to do $1!"
exit 3
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment