mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -08:00
feat: Improve bootstrap script to handle existing directories and cloning logic
This commit is contained in:
@@ -61,14 +61,24 @@ if ! command -v git &>/dev/null; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create shell directory if it doesn't exist
|
|
||||||
mkdir -p "$HOME/shell"
|
|
||||||
|
|
||||||
# Clone or update repository
|
# Clone or update repository
|
||||||
if [ -d "$DOTFILES_DIR" ]; then
|
if [ -d "$DOTFILES_DIR/.git" ]; then
|
||||||
echo -e "${YELLOW}Updating existing shell repository...${NC}"
|
echo -e "${YELLOW}Updating existing shell repository...${NC}"
|
||||||
cd "$DOTFILES_DIR"
|
cd "$DOTFILES_DIR"
|
||||||
git pull origin $DOTFILES_BRANCH
|
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
|
else
|
||||||
echo -e "${YELLOW}Cloning shell repository...${NC}"
|
echo -e "${YELLOW}Cloning shell repository...${NC}"
|
||||||
git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR"
|
git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR"
|
||||||
|
|||||||
Reference in New Issue
Block a user