Created
August 16, 2018 22:34
-
-
Save drhodes/c1ce517c1704d4daedef73259b0c60c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- sh -*- | |
#!/usr/bin/env bash | |
TMPFILE=/tmp/selfcontrol.temp | |
# remove self control from hosts | |
cat /etc/hosts | grep -v self-control > $TMPFILE | |
echo "# self-control" >> $TMPFILE | |
# if self control ON | |
if [[ $1 != "on" ]] | |
then if [[ $1 != "off" ]] | |
then echo "Expecting cmd line arg [on|off]" | |
exit 1 | |
fi | |
fi | |
cat ~/.selfcontrol | while read line | |
do | |
if [[ $1 == "on" ]] | |
then | |
echo 127.0.0.1 $line \# self-control >> $TMPFILE | |
fi | |
done | |
cp $TMPFILE /etc/hosts | |
rm $TMPFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
before using, you'll need to:
sudo chown $USER /etc/hosts
also you need a file called
~/.selfcontrol
with newline separated domain namesto activate filter:
$ selfcontrol on
to remove filter
$ selfcontrol off