Skip to content

Instantly share code, notes, and snippets.

@bennylope
Last active September 30, 2019 13:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennylope/dd0c723b6586ded254b3bd673a7861a3 to your computer and use it in GitHub Desktop.
Save bennylope/dd0c723b6586ded254b3bd673a7861a3 to your computer and use it in GitHub Desktop.
Block (from Samuel Mullen on Legacy Rocks slack)
# List the domains you want to block, one per line, in your ~/.blocked_sites file,
# then ensure this script is included or sourced in your terminal configuration.
function worktime {
while read -r line; do
echo "127.0.0.1 ${line} # WORKTIME"
echo "fe80::1%lo0 ${line} # WORKTIME"
echo "127.0.0.1 www.${line} # WORKTIME"
echo "fe80::1%lo0 www.${line} # WORKTIME"
done < $HOME/.blocked_sites | sudo tee -a /etc/hosts > /dev/null
}
function slacktime {
while read -r line; do
[[ $line =~ "# WORKTIME" ]] && continue
echo $line
done < /etc/hosts > /tmp/hosts
sudo cp /tmp/hosts /etc/hosts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment