From 666b66cd0c108d8ff7f3702cad4ac812fd671baf Mon Sep 17 00:00:00 2001 From: Max Richter Date: Wed, 11 Oct 2023 16:47:27 +0200 Subject: [PATCH] fix: install script --- install.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 284137c..294ad97 100755 --- a/install.sh +++ b/install.sh @@ -7,13 +7,27 @@ if [ "$(which git)" = "" ]; then fi # - Cloning Repo - -echo "-- Cloning repo --" cd $HOME -git init -git remote add origin https://github.com/jim-fx/.dotfiles.git -git checkout -f main +if [ -d ".git" ] || git rev-parse --git-dir > /dev/null 2>&1; then + # Get the remote URL + remote_url=$(git config --get remote.origin.url) + + # Check if the remote URL contains a certain word + if [[ $remote_url != *jim-fx/.dotfiles* ]]; then + echo "Error: There is already a git repository setup at $HOME that is not pointing to the dotfiles" + else + echo "-- updating dotfiles --" + git fetch + git checkout -f main + fi +else + echo "-- initializing dotfiles --" + git init + git remote add origin https://github.com/jim-fx/.dotfiles.git + git fetch + git checkout -f main +fi # - Executing the script - -echo "-- starting script --" -chmod +x ~/.dotfiles/setup.sh +echo "-- starting setup script --" ~/.dotfiles/setup.sh