Skip to content

Instantly share code, notes, and snippets.

@bennylope
Last active Sep 30, 2019
Embed
What would you like to do?
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