-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·127 lines (105 loc) · 4.05 KB
/
install.sh
File metadata and controls
executable file
·127 lines (105 loc) · 4.05 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
set -euo pipefail
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKUP_DIR="$HOME/.dotfiles-backup-$(date +%Y%m%d-%H%M%S)"
log() {
echo "🔧 $1"
}
error() {
echo "❌ $1" >&2
exit 1
}
backup_existing() {
local target="$1"
if [[ -e "$target" || -L "$target" ]]; then
log "Backing up existing $target to $BACKUP_DIR"
mkdir -p "$BACKUP_DIR"
mv "$target" "$BACKUP_DIR/"
fi
}
create_symlink() {
local source="$1"
local target="$2"
log "Linking $source -> $target"
backup_existing "$target"
mkdir -p "$(dirname "$target")"
ln -sf "$source" "$target"
}
main() {
log "Starting dotfiles installation from $DOTFILES_DIR"
# Install Homebrew dependencies
if command -v brew &> /dev/null; then
log "Installing Homebrew dependencies..."
brew bundle --file="$DOTFILES_DIR/Brewfile"
else
echo "⚠️ Homebrew not found. Please install Homebrew first:"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
echo " Then run this script again."
exit 1
fi
# Zsh configuration
create_symlink "$DOTFILES_DIR/zsh/.zshrc" "$HOME/.zshrc"
# Git configuration
create_symlink "$DOTFILES_DIR/git/.gitconfig" "$HOME/.gitconfig"
create_symlink "$DOTFILES_DIR/git/.gitignore_global" "$HOME/.gitignore_global"
# Git user configuration (personal info)
if [[ ! -f "$DOTFILES_DIR/private/git/user.gitconfig" ]]; then
log "Creating user git config from template..."
mkdir -p "$DOTFILES_DIR/private/git"
if [[ -f "$DOTFILES_DIR/git/user.gitconfig.template" ]]; then
cp "$DOTFILES_DIR/git/user.gitconfig.template" "$DOTFILES_DIR/private/git/user.gitconfig"
echo "⚠️ Please edit $DOTFILES_DIR/private/git/user.gitconfig with your git user details"
else
error "Template file not found at $DOTFILES_DIR/git/user.gitconfig.template"
fi
fi
if [[ -f "$DOTFILES_DIR/private/git/user.gitconfig" ]]; then
create_symlink "$DOTFILES_DIR/private/git/user.gitconfig" "$HOME/.gitconfig.user"
fi
# Starship prompt
create_symlink "$DOTFILES_DIR/starship/starship.toml" "$HOME/.config/starship.toml"
# Ghostty terminal
create_symlink "$DOTFILES_DIR/ghostty/config" "$HOME/.config/ghostty/config"
# Mise version manager
create_symlink "$DOTFILES_DIR/mise/config.toml" "$HOME/.config/mise/config.toml"
# Claude Code CLI
if ! command -v claude &> /dev/null; then
read -p "🤖 Install Claude Code CLI? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
log "Installing Claude Code CLI..."
curl -fsSL https://claude.ai/install.sh | bash
else
log "Skipping Claude Code CLI installation"
fi
else
log "Claude Code CLI already installed"
fi
# Zed editor
create_symlink "$DOTFILES_DIR/zed/settings.json" "$HOME/.config/zed/settings.json"
# Claude Code configuration (if it exists)
if [[ -f "$DOTFILES_DIR/claude/CLAUDE.md" ]]; then
create_symlink "$DOTFILES_DIR/claude" "$HOME/.claude"
fi
# Source private configurations if they exist
if [[ -d "$DOTFILES_DIR/private" ]]; then
log "Private directory found - symlinking private configs"
for private_file in "$DOTFILES_DIR/private"/*; do
if [[ -f "$private_file" && "$private_file" != */.keep ]]; then
filename=$(basename "$private_file")
create_symlink "$private_file" "$HOME/.config/private/$filename"
fi
done
fi
log "Installation complete! 🎉"
log ""
log "Next steps:"
log "1. Restart your terminal or run: source ~/.zshrc"
log "2. Install mise-managed tools: mise install"
log "3. If you use private configs, add them to the private/ directory"
log ""
if [[ -d "$BACKUP_DIR" ]]; then
log "Your original files were backed up to: $BACKUP_DIR"
fi
}
main "$@"