From e14eecd55b60ae2340bc22d77da022b00f084319 Mon Sep 17 00:00:00 2001 From: aerowin Date: Fri, 21 Oct 2022 14:13:12 -0500 Subject: [PATCH] Added dotfiles checkout check --- dotfiles.sh | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/dotfiles.sh b/dotfiles.sh index 0c63203..a9bf75d 100644 --- a/dotfiles.sh +++ b/dotfiles.sh @@ -6,28 +6,33 @@ read -e -p "Please paste a HTTPS link to your dotfiles repository (or press ente [[ -z $DOTFILES_URL ]] && DOTFILES_URL=https://github.com/fastai/dotfiles.git git clone --bare $DOTFILES_URL .cfg/ config checkout -config config --local status.showUntrackedFiles no -if [[ -s ~/.vimrc ]]; then - git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim - vim +PluginInstall +qall -fi -if [[ -f ~/.bashrc.local ]]; then - echo "source ~/.bashrc.local" >> ~/.bashrc -fi -if [[ -f ~/.bash_profile ]]; then - grep -q 'source ~/.bashrc' ~/.bash_profile 2>&1 || echo "source ~/.bashrc" >> ~/.bash_profile; -else - echo "Creating '.bash_profile'..." - echo "source ~/.bashrc" >> ~/.bash_profile -fi -. ~/.bashrc +# only continue if checkout had no errors +if [[ $? = 0 ]]; then + config config --local status.showUntrackedFiles no + if [[ -s ~/.vimrc ]]; then + git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim + vim +PluginInstall +qall + fi + if [[ -f ~/.bashrc.local ]]; then + echo "source ~/.bashrc.local" >> ~/.bashrc + fi + if [[ -f ~/.bash_profile ]]; then + grep -q 'source ~/.bashrc' ~/.bash_profile 2>&1 || echo "source ~/.bashrc" >> ~/.bash_profile; + else + echo "Creating '.bash_profile'..." + echo "source ~/.bashrc" >> ~/.bash_profile + fi + . ~/.bashrc -[[ -z $NAME ]] && read -e -p "Enter your name (for git configuration): " NAME -[[ -z $EMAIL ]] && read -e -p "Enter your email (for git configuration): " EMAIL -[[ $NAME ]] && git config --global user.name "$NAME" -[[ $EMAIL ]] && git config --global user.email "$EMAIL" -git config --global credential.helper cache -git config --global credential.helper 'cache --timeout=3600' - -cd - + [[ -z $NAME ]] && read -e -p "Enter your name (for git configuration): " NAME + [[ -z $EMAIL ]] && read -e -p "Enter your email (for git configuration): " EMAIL + [[ $NAME ]] && git config --global user.name "$NAME" + [[ $EMAIL ]] && git config --global user.email "$EMAIL" + git config --global credential.helper cache + git config --global credential.helper 'cache --timeout=3600' + cd - +else + echo "Error with dotfiles checkout, see above and retry." + rm -rf .cfg/ +fi