Initial zsh version of get-shit-done

This commit is contained in:
Yann Esposito (Yogsototh) 2011-05-06 09:58:53 +02:00
commit e4bf0c5896

61
get-shit-done Normal file
View file

@ -0,0 +1,61 @@
#!/usr/bin/env zsh
(($#<1)) && {
print -- "usage: ${0:t} (work|play)" >&2
exit 1;
}
hostfile=/etc/hosts
backupfile=$hostfile.orig
blacklist=( 'reddit.com'
'forums.somethingawful.com'
'somethingawful.com'
'digg.com'
'break.com'
'news.ycombinator.com'
'infoq.com'
'bebo.com'
'twitter.com'
'facebook.com'
'blip.com'
'youtube.com'
'vimeo.com'
'delicious.com'
'flickr.com'
'friendster.com'
'hi5.com'
'linkedin.com'
'livejournal.com'
'meetup.com'
'myspace.com'
'plurk.com'
'stickam.com'
'stumbleupon.com'
'yelp.com'
'slashdot.org' )
case $1 in
work)
[[ -e $backupfile ]] && {
print -- "$backupfile already exists, wou are in working mode" >&2
exit 1
}
\cp $hostfile $backupfile
for site in $blacklist; do
print -- "127.0.0.1\t$site"
print -- "127.0.0.1\twww.$site"
done >> $hostfile
;;
play)
\cp $backupfile $hostfile && \rm $backupfile
;;
*)
{
print -- "I don't know this option: '$*'"
print -- "use ${0:t} work or ${0:t} play"
exit 1
} >&2
esac
[[ -e /etc/init.d/networking ]] && /etc/init.d/networking restart