#!/bin/bash -e set -o pipefail [ "$NAME" ] || NAME= [ "$EMAIL" ] || EMAIL= [ "$IRCSET" ] || IRCSET= [ "$IRCSERVER" ] || IRCSERVER=irc.freenode.net [ "$IRCPORT" ] || IRCPORT=6667 [ "$IRCNICK" ] || IRCNICK=coward [ "$IRCPASS" ] || IRCPASS= [ "$DOTFILES" ] || DOTFILES="$HOME"/.dotfiles if [[ -f "$DOTFILES"/dotfilesrc ]]; then source "$DOTFILES"/dotfilesrc fi die() { echo "$1" 1>&2 && show_help && [ "$2" ] && [ "$2" -ge 0 ] && exit "$2" || exit 1; } # Show help function to be used below show_help() { echo "USAGE: setup.sh [arguments]" echo "ARGS:" cat <"$DOTFILES"/dotfilesrc < "$HOME"/.gitignore_global <"$DOTFILES"/files/gitconfig sed -e "s/%NAME%/$NAME/" | sed -e "s/%EMAIL%/$EMAIL/" > "$HOME"/.gitconfig cat "$DOTFILES"/files/tmux.conf > "$HOME"/.tmux.conf cat "$DOTFILES"/files/vimrc > "$HOME"/.vimrc if [[ ! -d "$HOME"/.oh-my-zsh ]]; then 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 cat "$DOTFILES"/files/zshrc > "$HOME"/.zshrc mkdir -p "$HOME"/bin cat "$DOTFILES"/files/tmux.sh > "$HOME"/bin/tmux.sh 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 if [[ ! -L "$HOME"/bin/setup.sh ]]; then ln -s "$DOTFILES"/setup.sh "$HOME"/bin fi