-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
85 lines (70 loc) · 2.32 KB
/
Copy pathbootstrap.sh
File metadata and controls
85 lines (70 loc) · 2.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
82
83
84
85
#!/usr/bin/env bash
set -e
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "=== Dev Setup Bootstrap ==="
echo "Repo dir: $REPO_DIR"
echo
# 1. Cài các package Ubuntu
if [ -d "$REPO_DIR/ubuntu" ]; then
echo "[bootstrap] Running Ubuntu apt installer..."
"$REPO_DIR/ubuntu/install.sh"
else
echo "[bootstrap] No ubuntu/ dir found, skipping apt install."
fi
# 2. Symlink dotfiles
echo
echo "[bootstrap] Linking dotfiles..."
link_file() {
local src="$1"
local dest="$2"
if [ -e "$dest" && ! -L "$dest" ]; then
echo " [skip] $dest exists (not symlink). Backup or remove manually."
return
fi
mkdir -p "$(dirname "$dest")"
ln -sf "$src" "$dest"
echo " [link] $src -> $dest"
}
DOTFILES=(
"shell/zshrc:$HOME/.zshrc"
"shell/p10k.zsh:$HOME/.p10k.zsh"
"shell/aliases:$HOME/.aliases"
"shell/functions:$HOME/.functions"
"shell/exports:$HOME/.exports"
"shell/zprofile:$HOME/.zprofile"
"shell/gitconfig:$HOME/.gitconfig"
"shell/gitignore_global:$HOME/.gitignore_global"
)
for item in "${DOTFILES[@]}"; do
src="$REPO_DIR/${item%%:*}"
dest="${item##*:}"
if [ -f "$src" ]; then
link_file "$src" "$dest"
fi
done
# 3. Cài Node + Yarn
echo
if [ -d "$REPO_DIR/node" ]; then
echo "[bootstrap] Running Node/Yarn installer..."
"$REPO_DIR/node/install-node.sh"
else
echo "[bootstrap] No node/ dir found, skipping node install."
fi
# 4. Copy Windows Terminal settings (nếu đang chạy WSL trên Windows)
echo
if [ -f "$REPO_DIR/windows-terminal/settings.json" ] && command -v powershell.exe >/dev/null 2>&1; then
echo "[bootstrap] Updating Windows Terminal settings via PowerShell..."
WIN_SETTINGS_SRC_WIN="$(wslpath -w "$REPO_DIR/windows-terminal/settings.json")"
powershell.exe -NoProfile -Command "
\$src = '$WIN_SETTINGS_SRC_WIN';
\$destDir = Join-Path \$env:LOCALAPPDATA 'Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState';
New-Item -ItemType Directory -Force -Path \$destDir | Out-Null;
Copy-Item -Path \$src -Destination (Join-Path \$destDir 'settings.json') -Force;
"
echo "[bootstrap] Windows Terminal settings copied. Restart Windows Terminal to see changes."
else
echo "[bootstrap] Skipping Windows Terminal settings (file missing or not on Windows)."
fi
echo
echo "=== DONE ==="
echo "Mở terminal WSL mới (hoặc 'exec zsh') để load lại config."