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