📥 Updated install script with Dotbot

This commit is contained in:
Alicia Sykes 2022-03-12 19:27:04 +00:00
parent dd833e1ce5
commit 9cc380c50e
3 changed files with 33 additions and 43 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "dotbot"]
path = dotbot
url = https://github.com/anishathalye/dotbot

1
dotbot Submodule

@ -0,0 +1 @@
Subproject commit 4ec846cdad4c5f6996523e7015f0b36a6b40e9f6

View File

@ -3,16 +3,15 @@
# For docs and dotfiles, see: https://github.com/lissy93/dotfiles # For docs and dotfiles, see: https://github.com/lissy93/dotfiles
# Licensed under MIT - (C) Alicia Sykes, 2022 <https://aliciasykes.com> # Licensed under MIT - (C) Alicia Sykes, 2022 <https://aliciasykes.com>
# Paths and Settings set -e
YADM_REPO_NAME="Lissy93/Dotfiles"
YADM_REPO="https://github.com/${YADM_REPO_NAME}.git" REPO_NAME="Lissy93/Dotfiles"
# https://github.com/Lissy93/Dotfiles.git REPO_PATH="https://github.com/${REPO_NAME}.git"
# git@github.com:${YADM_REPO}.git
DOTFILES_DIR="/home/alicia/Documents/personal-projects/dotfiles" CONFIG=".install.conf.yaml"
# DOTFILES_DIR="~/dotfiles" DOTBOT_DIR="dotbot"
YADM_DATA="$HOME/.local/share/yadm" DOTBOT_BIN="bin/dotbot"
BIN_PATH="$HOME/.local/bin" DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
YADM_BIN="$BIN_PATH/yadm"
TITLE='🧰 Lissy93/Dotfiles Setup' TITLE='🧰 Lissy93/Dotfiles Setup'
# Color Variables # Color Variables
@ -58,10 +57,10 @@ terminate () {
system_verify () { system_verify () {
if ! command_exists $1; then if ! command_exists $1; then
if $2; 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 terminate
else 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
fi fi
} }
@ -74,7 +73,7 @@ system_verify "zsh" false
system_verify "vim" false system_verify "vim" false
system_verify "git" true system_verify "git" true
system_verify "tmux" false system_verify "tmux" false
system_verify "yadm" false system_verify "antigen" false
# If on Mac, offer to install Brew # If on Mac, offer to install Brew
if [ "$system_type" = "Darwin" ] && ! command_exists brew; then if [ "$system_type" = "Darwin" ] && ! command_exists brew; then
@ -86,38 +85,15 @@ if [ "$system_type" = "Darwin" ] && ! command_exists brew; then
fi fi
fi fi
# Offer to install YADM if not setup # Download / update dotfiles repo with Chezmoi
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
if [[ ! -d "$DOTFILES_DIR" ]] if [[ ! -d "$DOTFILES_DIR" ]]
then 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}" mkdir -p "${DOTFILES_DIR}"
cd "${DOTFILES_DIR}" && yadm clone ${YADM_REPO} git clone --recursive ${REPO_PATH} ${DOTFILES_DIR}
else else
echo -e "Pulling changes from ${YADM_REPO_NAME} into ${DOTFILES_DIR}" echo -e "Pulling changes from ${REPO_NAME} into ${DOTFILES_DIR}"
cd "${DOTFILES_DIR}" && yadm pull cd "${DOTFILES_DIR}" && git pull
fi fi
# If git clone / pull failed, then exit with error # If git clone / pull failed, then exit with error
@ -128,13 +104,23 @@ then
terminate terminate
fi fi
# If on Mac, update Brew bundle # # If on Mac, update Brew bundle
if [ "$system_type" = "Darwin" ] && command_exists brew && [ -f "$HOME/.Brewfile" ] if [ "$system_type" = "Darwin" ] && command_exists brew && [ -f "$HOME/.Brewfile" ]
then then
echo "Updating homebrew bundle" echo "Updating homebrew bundle"
brew bundle --global brew bundle --global
fi 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 # Print success message, and time taken
total_time=$((`date +%s`-start_time)) total_time=$((`date +%s`-start_time))
make_banner "✨ Dotfiles configured succesfully in $total_time seconds" ${GREEN_B} 1 make_banner "✨ Dotfiles configured succesfully in $total_time seconds" ${GREEN_B} 1