2015-03-05 16:54:46 +00:00
#!/bin/bash -e
CMD = " $0 "
[ " $NAME " ] || NAME =
[ " $EMAIL " ] || EMAIL =
[ " $IRCSERVER " ] || IRCSERVER = irc.freenode.net
[ " $IRCPORT " ] || IRCPORT = 6667
[ " $IRCNICK " ] || IRCNICK = coward
[ " $IRCPASS " ] || IRCPASS =
die( ) { echo " $1 " 1>& 2 && show_help && [ " $2 " ] && [ " $2 " -ge 0 ] && exit " $2 " || exit 1; }
# Show help function to be used below
show_help( ) {
awk 'NR>1{print} /^(###|$)/{exit}' " $CMD "
echo " USAGE: $( basename " $CMD " ) [arguments] "
echo "ARGS:"
MSG = $( awk '/^NARGS=-1; while/,/^esac; done/' " $CMD " | sed -e 's/^[[:space:]]*/ /' -e 's/|/, /' -e 's/)//' | grep '^ -' )
EMSG = $( eval " echo \" $MSG \" " )
echo " $EMSG "
}
# Parse command line options (odd formatting to simplify show_help() above)
NARGS = -1; while [ " $# " -ne " $NARGS " ] ; do NARGS = $# ; case $1 in
# SWITCHES
-h| --help) # This help message
show_help; exit 1; ; ;
-n| --name) # Name for git
shift && NAME = " $1 " && shift; ; ;
-e| --email) # Email for git
shift && EMAIL = " $1 " && shift; ; ;
-s| --server) # server for irssi
shift && IRCSERVER = " $1 " && shift; ; ;
-P| --port) # port for irssi
shift && IRCPORT = " $1 " && shift; ; ;
-N| --nick) # nick for irssi
shift && IRCNICK = " $1 " && shift; ; ;
-p| --password) # password for irssi
shift && IRCPASS = " $1 " && shift; ; ;
esac ; done
[ " $NAME " ] || die "You must provide a name!"
[ " $EMAIL " ] || die "You must provide an email!"
fn_distro( ) {
if [ -f /etc/lsb-release ] ; then
os = $( lsb_release -s -d)
elif [ -f /etc/debian_version ] ; then
os = " Debian $( cat /etc/debian_version) "
elif [ -f /etc/redhat-release ] ; then
os = $( cat /etc/redhat-release)
else
os = " $( uname -s) $( uname -r) "
fi
}
UNAMESTR = $( uname)
if [ [ " $UNAMESTR " = = 'Linux' ] ] ; then
fn_distro
if [ [ " $os " = = Ubuntu* ] ] ; then
sudo apt-get install -y build-essential git irssi vim-nox zsh tmux
fi
elif [ [ " $UNAMESTR " = = 'Darwin' ] ] ; then
# Probably need to set up brew and brew install some stuff here...
true
fi
2015-03-05 17:26:59 +00:00
git clone git@git.chrissexton.org:cws/dotfiles.git " $HOME " /.dotfiles
DOTFILES = " $HOME " /.dotfiles
2015-03-05 16:54:46 +00:00
2015-03-05 17:26:59 +00:00
cat " $DOTFILES " /files/gitignore_global > " $HOME " /.gitignore_global
2015-03-05 16:54:46 +00:00
2015-03-05 17:26:59 +00:00
<" $DOTFILES " /files/gitconfig sed -e " s/%NAME%/ $NAME / " | sed -e " s/%EMAIL%/ $EMAIL / " > " $HOME " /.gitconfig
2015-03-05 16:54:46 +00:00
2015-03-05 17:26:59 +00:00
cat " $DOTFILES " /files/tmux.conf > " $HOME " /.tmux.conf
2015-03-05 16:54:46 +00:00
2015-03-05 17:26:59 +00:00
cat " $DOTFILES " /files/vimrc > " $HOME " /.vimrc
2015-03-05 16:54:46 +00:00
2015-03-05 17:26:59 +00:00
if [ [ ! -d " $HOME " /.oh-my-zsh ] ] ; then
2015-03-05 16:54:46 +00:00
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
fi
if [ [ ! " $SHELL " = ~ .*zsh ] ] ; then
chsh -s " $( which zsh) "
fi
2015-03-05 17:26:59 +00:00
cat " $DOTFILES " /files/zshrc > " $HOME " /.zshrc
2015-03-05 16:54:46 +00:00
2015-03-05 17:26:59 +00:00
mkdir -p " $HOME " /bin
cat " $DOTFILES " /files/tmux.sh > " $HOME " /bin/tmux.sh
2015-03-05 16:54:46 +00:00
2015-03-05 17:26:59 +00:00
mkdir -p " $HOME " /.irssi
<" $DOTFILES " /files/irssiconfig sed -e " s/%PASSWORD%/ $IRCPASS / " | sed -e " s/%NICK%/ $IRCNICK / " | sed -e " s/%SERVER%/ $IRCSERVER / " | sed -e " s/%PORT%/ $IRCPORT / " > " $HOME " /.irssi/config