4 ms·
Optimized version: # turn on sudo rm /etc/hosts sudo ln -s /etc/hosts{.work,} # turn off sudo rm /etc/hosts sudo ln -s /etc/hosts{.play,} Optimized furth
by Supreme 14y ago
Optimized version:
# turn on
sudo rm /etc/hosts
sudo ln -s /etc/hosts{.work,}
# turn off
sudo rm /etc/hosts
sudo ln -s /etc/hosts{.play,}
Optimized further (in your ~/.bashrc):
alias work="sudo rm /etc/hosts && sudo ln -s /etc/hosts{.work,}"
alias play="sudo rm /etc/hosts && sudo ln -s /etc/hosts{.play,}"
Optimization cubed (lets you define a base hosts file):
alias work="sudo rm /etc/hosts && sudo cat /etc/hosts.base >> /etc/hosts && sudo cat /etc/hosts.work >> /etc/hosts"
alias play=...
The number of upvotes, the fact that you thought this was necessary and the fact that this application exists all made me facepalm hard. I can't even see right now.
- pseudonym 14y agoThis is close to what I have, except less complex. A single line in /etc/hosts that redirects sites to 127.0.0.1, which gets commented or uncommented. The fact that I have to go through the hassle of sudoing up and removing the comment means I'm far more likely to catch myself before doing it and getting back to work.
- Supreme 14y agoOptimization #4: alias play="sleep 120 && ..." Two minutes should be enough for the craving to pass :-)
- srijan4 14y agoI upvoted so that others share their similar setups/scripts (as you did).