-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
82 lines (71 loc) · 3.32 KB
/
bootstrap.sh
File metadata and controls
82 lines (71 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# ============================================================================
# bootstrap.sh — One-liner dotfiles installer
#
# Usage:
# bash -c "$(curl -fsSL https://raw.githubusercontent.com/noofreuuuh/Dotfiles/main/bootstrap.sh)"
#
# Or clone manually:
# git clone https://github.com/noofreuuuh/Dotfiles.git ~/Dotfiles && cd ~/Dotfiles && bash main.sh
# ============================================================================
set -eo pipefail
REPO="https://github.com/noofreuuuh/Dotfiles.git"
DEFAULT_DEST="$(pwd)/Dotfiles"
# Colors
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'
BOLD='\033[1m'; DIM='\033[2m'; RESET='\033[0m'
echo -e "${CYAN}"
echo " ██████╗ ██████╗ ████████╗███████╗██╗██╗ ███████╗███████╗"
echo " ██╔══██╗██╔═══██╗╚══██╔══╝██╔════╝██║██║ ██╔════╝██╔════╝"
echo " ██║ ██║██║ ██║ ██║ █████╗ ██║██║ █████╗ ███████╗"
echo " ██║ ██║██║ ██║ ██║ ██╔══╝ ██║██║ ██╔══╝ ╚════██║"
echo " ██████╔╝╚██████╔╝ ██║ ██║ ██║███████╗███████╗███████║"
echo " ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝"
echo -e "${RESET}"
echo -e " ${BOLD}Dotfiles Bootstrap${RESET} ${DIM}by Noofreuuuh${RESET}"
echo ""
# Check git
if ! command -v git &>/dev/null; then
echo -e "${RED}[ERROR]${RESET} git is required. Installing Xcode Command Line Tools..."
xcode-select --install 2>/dev/null || true
echo -e "${DIM}Re-run this script after CLT installation completes.${RESET}"
exit 1
fi
# Resolve installation directory
echo -e " ${BOLD}Installation directory${RESET}"
echo -e " ${DIM}Default: ${DEFAULT_DEST}${RESET}"
echo ""
read -p " Install here? [Y/n] " _confirm
if [[ "$_confirm" =~ ^[Nn]$ ]]; then
while true; do
read -p " Enter path: " _custom
# Expand ~ manually since read doesn't expand it
_custom="${_custom/#\~/$HOME}"
if [[ -n "$_custom" ]]; then
DEST="$_custom"
break
fi
echo -e " ${RED}[ERROR]${RESET} Path cannot be empty."
done
else
DEST="$DEFAULT_DEST"
fi
echo ""
# Clone or update
if [[ -d "$DEST/.git" ]]; then
echo -e "${DIM}[INFO]${RESET} Existing repo found at ${DEST} — pulling latest..."
if ! git -C "$DEST" pull --ff-only 2>&1; then
echo -e "${RED}[ERROR]${RESET} git pull failed. The local repo may have uncommitted changes or a diverged branch."
echo -e "${DIM} To fix: cd ${DEST} && git fetch origin && git reset --hard origin/main${RESET}"
exit 1
fi
else
echo -e "${DIM}[INFO]${RESET} Cloning dotfiles to ${DEST}..."
git clone "$REPO" "$DEST"
fi
echo ""
echo -e "${GREEN}[OK]${RESET} Repository ready at ${BOLD}${DEST}${RESET}"
echo -e "${DIM} Launching setup...${RESET}"
echo ""
sleep 1
bash "${DEST}/main.sh" "$@"