diff --git a/setup/bootstrap.sh b/setup/bootstrap.sh index 5326115..388ec6d 100755 --- a/setup/bootstrap.sh +++ b/setup/bootstrap.sh @@ -61,14 +61,24 @@ if ! command -v git &>/dev/null; then esac fi -# Create shell directory if it doesn't exist -mkdir -p "$HOME/shell" - # Clone or update repository -if [ -d "$DOTFILES_DIR" ]; then +if [ -d "$DOTFILES_DIR/.git" ]; then echo -e "${YELLOW}Updating existing shell repository...${NC}" cd "$DOTFILES_DIR" git pull origin $DOTFILES_BRANCH +elif [ -d "$DOTFILES_DIR" ]; then + echo -e "${YELLOW}Directory exists but is not a git repository.${NC}" + # Check if directory is empty + if [ -z "$(ls -A "$DOTFILES_DIR")" ]; then + echo -e "${YELLOW}Directory is empty. Cloning...${NC}" + git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR" + else + echo -e "${YELLOW}Backing up existing directory...${NC}" + mv "$DOTFILES_DIR" "${DOTFILES_DIR}.bak.$(date +%s)" + echo -e "${YELLOW}Cloning shell repository...${NC}" + git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR" + fi + cd "$DOTFILES_DIR" else echo -e "${YELLOW}Cloning shell repository...${NC}" git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR"