3 ms·
Yep, beware I didn't even tested it: #!/usr/bin/env zsh (($#<1)) && { print -- "usage: $0:t (play|work)" exit 1 }>&2 black
by yogsototh 15y ago
Yep, beware I didn't even tested it:
#!/usr/bin/env zsh
(($#<1)) && {
print -- "usage: $0:t (play|work)"
exit 1
}>&2
blacklist=(
reddit.com
ycombinator.com
slashdot.com
)
hostfile=/etc/host
if [[ $1 = "play" ]]; then
if [[ ! -e $hostfile.orig ]]; then
cp $hostfile{,.orig}
else
print -- "You're already playin" >&2
exit 1
fi
cp $hostfile{.orig,}
for elem in $blacklist; do
print -- "127.0.0.1\t$elem" >> /etc/host
print -- "127.0.0.1\twww.$elem" >> /etc/host
done
fi
if [[ $1 = "work" ]]; then
cp $hostfile{.orig,}
\rm $hostfile.orig
fi
/etc/init.d/networking restart