Repository navigation
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·62 lines (52 loc) · 1.56 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·62 lines (52 loc) · 1.56 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
#!/bin/bash
set -euo pipefail
REPO_RAW="https://raw.githubusercontent.com/ThomasCode92/dotfiles/main"
# DOTFILES_LOCAL=1 -> use the scripts from the local chezmoi source directory
# instead of downloading. Hardcoded because `curl ... | bash` leaves
# BASH_SOURCE unset.
DOTFILES_LOCAL="${DOTFILES_LOCAL:-0}"
SCRIPT_DIR="$HOME/.local/share/chezmoi"
echo "🚀 Setting up dotfiles"
# ---------------------------------------------------------
# Detect OS
# ---------------------------------------------------------
case "$(uname -s)" in
Darwin)
SCRIPT="bootstrap-macos.sh"
echo "🍎 macOS detected"
;;
Linux)
if [[ -f /etc/arch-release ]]; then
SCRIPT="bootstrap-arch.sh"
echo "🐧 Arch Linux detected"
else
echo "❌ Unsupported Linux distribution (only Arch is supported)"
exit 1
fi
;;
*)
echo "❌ Unsupported operating system"
exit 1
;;
esac
# ---------------------------------------------------------
# Run the OS-specific script (local copy or download)
# ---------------------------------------------------------
if [[ "$DOTFILES_LOCAL" == "1" ]]; then
if [[ ! -f "$SCRIPT_DIR/$SCRIPT" ]]; then
echo "❌ $SCRIPT not found in $SCRIPT_DIR (run chezmoi init first)"
exit 1
fi
echo "📁 Using local $SCRIPT"
bash "$SCRIPT_DIR/$SCRIPT" "$@"
else
TMP_SCRIPT="$(mktemp)"
trap 'rm -f "$TMP_SCRIPT"' EXIT
if ! command -v curl &>/dev/null; then
echo "❌ curl is required to download $SCRIPT"
exit 1
fi
echo "⬇️ Downloading $SCRIPT"
curl -fsSL "$REPO_RAW/$SCRIPT" -o "$TMP_SCRIPT"
bash "$TMP_SCRIPT" "$@"
fi