Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 28 lines (20 sloc) 614 Bytes
#!/bin/bash
set -eo pipefail
# Get /etc/hosts file to block ads at the networking level
curl -s http://winhelp2002.mvps.org/hosts.txt > /tmp/adblock
# Re-write Windows to Unix line endings
tr -d '\r' < /tmp/adblock > /tmp/etchosts
comment() {
replace "0.0.0.0 $1" "# 0.0.0.0 $1" /tmp/etchosts
}
# Comment-out used hosts
comment 'ads.twitter.com'
comment 'api.segment.io'
comment 'static.ads-twitter.com'
# Add /etc/hosts overrides
echo '# MacOS default
255.255.255.255 broadcasthost' >> /tmp/etchosts
# Update /etc/hosts
sudo mv /tmp/etchosts /etc/hosts
# Flush DNS cache
sudo killall -HUP mDNSResponder
You can’t perform that action at this time.