From 225b3f0b5011aab92c6da20b922b9151c4fc3c4b Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Thu, 5 Mar 2015 15:02:38 -0500 Subject: [PATCH] Add saved settings --- .gitignore | 1 + setup.sh | 54 +++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 .gitignore mode change 100644 => 100755 setup.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1df7e9e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dotfilesrc diff --git a/setup.sh b/setup.sh old mode 100644 new mode 100755 index 9b0fd77..42038a4 --- a/setup.sh +++ b/setup.sh @@ -11,6 +11,10 @@ set -o pipefail [ "$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 @@ -50,32 +54,32 @@ NARGS=-1; while [ "$#" -ne "$NARGS" ]; do NARGS=$#; case $1 in shift && IRCPASS="$1" && IRCSET=1 && shift; ;; esac; done -if [ ! "$NAME" ]; then - read -e -p "Git author name: " NAME +if [[ ! "$NAME" ]]; then + read -e -p "Git author name [$USER]: " NAME fi -[ "$NAME" ] || die "You must specify a Git author name" -if [ ! "$EMAIL" ]; then - read -e -p "Git author email: " EMAIL +[ "$NAME" ] || NAME="$USER" +if [[ ! "$EMAIL" ]]; then + read -e -p "Git author email [$USER@$(hostname)]: " EMAIL fi -[ "$EMAIL" ] || die "You must specify a Git author email" -if [ ! "$IRCSET" ]; then - read -e -p "Would you like to set up irssi [Y/n]? " -i"n" yn +[ "$EMAIL" ] || EMAIL="$USER@$(hostname)" +if [[ ! "$IRCSET" ]]; then + read -e -p "Would you like to set up irssi [y/N]? " yn case $yn in [Yy]* ) - read -e -p "irssi server: " -i"irc.freenode.net" IRCSERVER - read -e -p "irssi port: " -i"6667" IRCPORT - read -e -p "irssi nick: " -i"coward" IRCNICK - read -e -p "irssi psasword: " IRCPASS + read -e -p "irssi server [$IRCSERVER]: " IRCSERVER + read -e -p "irssi port [$IRCPORT]: " IRCPORT + read -e -p "irssi nick [$IRCNICK]: " IRCNICK + read -e -p "irssi psasword []: " IRCPASS ;; esac fi fn_distro(){ - if [ -f /etc/lsb-release ]; then + if [[ -f /etc/lsb-release ]]; then os=$(lsb_release -s -d) - elif [ -f /etc/debian_version ]; then + elif [[ -f /etc/debian_version ]]; then os="Debian $(cat /etc/debian_version)" - elif [ -f /etc/redhat-release ]; then + elif [[ -f /etc/redhat-release ]]; then os=$(cat /etc/redhat-release) else os="$(uname -s) $(uname -r)" @@ -93,12 +97,24 @@ elif [[ "$UNAMESTR" == 'Darwin' ]]; then true fi -if [ ! -d "$DOTFILES" ]; then +if [[ ! -d "$DOTFILES" ]]; then git clone git@git.chrissexton.org:cws/dotfiles.git "$DOTFILES" -elif [ ! -d "$DOTFILES"/files ]; then +elif [[ ! -d "$DOTFILES"/files ]]; then die "You must have a destination for the dotfiles repository!" fi +cat >"$DOTFILES"/dotfilesrc < "$HOME"/.gitignore_global <"$DOTFILES"/files/gitconfig sed -e "s/%NAME%/$NAME/" | sed -e "s/%EMAIL%/$EMAIL/" > "$HOME"/.gitconfig @@ -122,3 +138,7 @@ 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