From 9cc380c50ed1e7bd761fe371f99fb1e41fced5d9 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 12 Mar 2022 19:27:04 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A5=20Updated=20install=20script=20wit?= =?UTF-8?q?h=20Dotbot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 +++ dotbot | 1 + install.sh | 72 +++++++++++++++++++++-------------------------------- 3 files changed, 33 insertions(+), 43 deletions(-) create mode 100644 .gitmodules create mode 160000 dotbot diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1ce5c11 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dotbot"] + path = dotbot + url = https://github.com/anishathalye/dotbot diff --git a/dotbot b/dotbot new file mode 160000 index 0000000..4ec846c --- /dev/null +++ b/dotbot @@ -0,0 +1 @@ +Subproject commit 4ec846cdad4c5f6996523e7015f0b36a6b40e9f6 diff --git a/install.sh b/install.sh index 7b585c6..4b1ca9d 100644 --- a/install.sh +++ b/install.sh @@ -3,16 +3,15 @@ # For docs and dotfiles, see: https://github.com/lissy93/dotfiles # Licensed under MIT - (C) Alicia Sykes, 2022 -# Paths and Settings -YADM_REPO_NAME="Lissy93/Dotfiles" -YADM_REPO="https://github.com/${YADM_REPO_NAME}.git" -# https://github.com/Lissy93/Dotfiles.git -# git@github.com:${YADM_REPO}.git -DOTFILES_DIR="/home/alicia/Documents/personal-projects/dotfiles" -# DOTFILES_DIR="~/dotfiles" -YADM_DATA="$HOME/.local/share/yadm" -BIN_PATH="$HOME/.local/bin" -YADM_BIN="$BIN_PATH/yadm" +set -e + +REPO_NAME="Lissy93/Dotfiles" +REPO_PATH="https://github.com/${REPO_NAME}.git" + +CONFIG=".install.conf.yaml" +DOTBOT_DIR="dotbot" +DOTBOT_BIN="bin/dotbot" +DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" TITLE='🧰 Lissy93/Dotfiles Setup' # Color Variables @@ -31,7 +30,7 @@ system_type=$(uname -s) # Function that prints important text in a banner with colored border # First param is the text to output, then optional color and padding -make_banner () { +make_banner () { bannerText=$1 lineColor="${2:-$CYAN_B}" padding="${3:-0}" @@ -58,10 +57,10 @@ terminate () { system_verify () { if ! command_exists $1; then if $2; then - echo -e "🚫 ${RED_B}Error:${PLAIN_B} $1 is not installed" + echo -e "🚫 ${RED_B}Error:${PLAIN_B} $1 is not installed${RESET}" terminate else - echo -e "⚠️ ${YELLOW_B}Warning:${PLAIN_B} $1 is not installed" + echo -e "⚠️ ${YELLOW_B}Warning:${PLAIN_B} $1 is not installed${RESET}" fi fi } @@ -74,7 +73,7 @@ system_verify "zsh" false system_verify "vim" false system_verify "git" true system_verify "tmux" false -system_verify "yadm" false +system_verify "antigen" false # If on Mac, offer to install Brew if [ "$system_type" = "Darwin" ] && ! command_exists brew; then @@ -86,38 +85,15 @@ if [ "$system_type" = "Darwin" ] && ! command_exists brew; then fi fi -# Offer to install YADM if not setup -if ! command_exists yadm && ! [ -a "${YADM_BIN}" ]; then - read -p "Install YDAM now? (y/N)" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - if command_exists brew && [ "$system_type" = "Darwin" ]; then - brew install yadm - else - echo "Installing YADM into ${YADM_DATA}\n" - git clone https://github.com/TheLocehiliosan/yadm.git $YADM_DATA - mkdir -p $BIN_PATH; ln -s $YADM_DATA/yadm $YADM_BIN - fi - else - echo "🚫 YDAM is required, exiting setup..." && exit 1 - fi -fi - -# If YADM alias not set, then point it to yadm binary -if ! command_exists yadm; then - shopt -s expand_aliases - alias yadm=$YADM_BIN -fi - -# Download / update dotfiles repo with YADM +# Download / update dotfiles repo with Chezmoi if [[ ! -d "$DOTFILES_DIR" ]] then - echo "Dotfiles not yet present. Will download ${YADM_REPO_NAME} into ${DOTFILES_DIR}" + echo "Dotfiles not yet present. Will download ${REPO_NAME} into ${DOTFILES_DIR}" mkdir -p "${DOTFILES_DIR}" - cd "${DOTFILES_DIR}" && yadm clone ${YADM_REPO} + git clone --recursive ${REPO_PATH} ${DOTFILES_DIR} else - echo -e "Pulling changes from ${YADM_REPO_NAME} into ${DOTFILES_DIR}" - cd "${DOTFILES_DIR}" && yadm pull + echo -e "Pulling changes from ${REPO_NAME} into ${DOTFILES_DIR}" + cd "${DOTFILES_DIR}" && git pull fi # If git clone / pull failed, then exit with error @@ -128,13 +104,23 @@ then terminate fi -# If on Mac, update Brew bundle +# # If on Mac, update Brew bundle if [ "$system_type" = "Darwin" ] && command_exists brew && [ -f "$HOME/.Brewfile" ] then echo "Updating homebrew bundle" brew bundle --global fi +# Set up symlinks with dotbo +cd "${DOTFILES_DIR}" +git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive +git submodule update --init --recursive "${DOTBOT_DIR}" + +"${DOTFILES_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${DOTFILES_DIR}" -c "${CONFIG}" "${@}" + +# Update source to ZSH entry point +source "${HOME}/.zshenv" + # Print success message, and time taken total_time=$((`date +%s`-start_time)) make_banner "✨ Dotfiles configured succesfully in $total_time seconds" ${GREEN_B} 1