-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·82 lines (67 loc) · 2.12 KB
/
install.sh
File metadata and controls
executable file
·82 lines (67 loc) · 2.12 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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
usage() {
echo "Usage: $0 <profile>"
echo " profile: name of a directory under profiles/ (e.g., personal, work)"
echo ""
echo "Available profiles:"
for d in "$SCRIPT_DIR"/profiles/*/; do
echo " $(basename "$d")"
done
exit 1
}
if [ $# -ne 1 ]; then
usage
fi
PROFILE="$1"
PROFILE_DIR="$SCRIPT_DIR/profiles/$PROFILE"
if [ ! -d "$PROFILE_DIR" ]; then
echo "Error: profile '$PROFILE' not found at $PROFILE_DIR"
usage
fi
# Backup a file if it exists and is not already a symlink
backup() {
local target="$1"
if [ -e "$target" ] && [ ! -L "$target" ]; then
local backup="${target}.bak.$(date +%Y%m%d%H%M%S)"
echo " Backing up $target -> $backup"
mv "$target" "$backup"
fi
}
# Create a symlink, backing up any existing non-symlink file
link() {
local src="$1"
local dst="$2"
# Create parent directory if needed
mkdir -p "$(dirname "$dst")"
backup "$dst"
# Remove existing symlink if present
[ -L "$dst" ] && rm "$dst"
ln -s "$src" "$dst"
echo " $dst -> $src"
}
echo "Installing config with profile: $PROFILE"
echo ""
# Shared core files
echo "Linking shared config:"
link "$SCRIPT_DIR/.zshrc" "$HOME/.zshrc"
link "$SCRIPT_DIR/.emacs.d" "$HOME/.emacs.d"
link "$SCRIPT_DIR/.gitconfig" "$HOME/.gitconfig"
link "$SCRIPT_DIR/.gitignore_global" "$HOME/.gitignore_global"
link "$SCRIPT_DIR/.tmux.conf" "$HOME/.tmux.conf"
link "$SCRIPT_DIR/.config/starship.toml" "$HOME/.config/starship.toml"
link "$SCRIPT_DIR/.claude/CLAUDE.md" "$HOME/.claude/CLAUDE.md"
link "$SCRIPT_DIR/.claude/statusline.sh" "$HOME/.claude/statusline.sh"
echo ""
# Profile-specific overrides
echo "Linking profile overrides ($PROFILE):"
link "$PROFILE_DIR/claude-settings.json" "$HOME/.claude/settings.json"
for file in "$PROFILE_DIR"/.*; do
basename="$(basename "$file")"
# Skip . and ..
[ "$basename" = "." ] || [ "$basename" = ".." ] && continue
link "$file" "$HOME/$basename"
done
echo ""
echo "Done. Profile '$PROFILE' installed."