hosts-timer
Block websites on your system with /etc/hosts
, and re-enable them on demand for a specified amount of time.
Installation
Requires Go to be installed (tested with Go 1.15.x).
git clone https://github.com/cdzombak/hosts-timer.git
cd hosts-timer
make install
Usage
Setup for domain(s)
sudo hosts-timer -install facebook.com twitter.com
(-disable
is an alias for -install
, which disables the given sites.)
Use a site for a specified duration of time
sudo hosts-timer -time 5m twitter.com
Durations must be acceptable by time.ParseDuration
.
Remove hosts-timer block for domain(s)
sudo hosts-timer -uninstall twitter.com facebook.com
(-enable
is an alias for -uninstall
, which enables the given sites.)
Setup Hints
.zshrc
helpers
function use-facebook() {
if [ $# -eq 0 ]; then
echo "Usage: use-facebook DURATION"
echo " eg. use-facebook 5m"
return 1
fi
sudo hosts-timer -time "$1" facebook.com
}
function use-twitter() {
if [ $# -eq 0 ]; then
echo "Usage: use-twitter DURATION"
echo " eg. use-twitter 5m"
return 1
fi
sudo hosts-timer -time "$1" twitter.com
}
Alfred helpers
Install the included Alfred helpers, and then you can use Alfred to enable Twitter or Facebook for a given amount of time (default 5 minutes).
/etc/sudoers.d/hosts-timer
Create cdzombak ALL=NOPASSWD: /usr/local/bin/hosts-timer
And then:
sudo chown root:wheel /etc/sudoers.d/hosts-timer
sudo chmod 440 /etc/sudoers.d/hosts-timer
Author
Chris Dzombak