-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·213 lines (175 loc) · 8.3 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·213 lines (175 loc) · 8.3 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/usr/bin/env bash
# ══════════════════════════════════════════════════════════════════════════════
# Dotfiles Installer — One command, full terminal setup
# Usage: git clone <repo> ~/.dotfiles && ~/.dotfiles/install.sh
# ══════════════════════════════════════════════════════════════════════════════
set -euo pipefail
# ─── Colors ──────────────────────────────────────────────────────────────────
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m'
info() { echo -e "${BLUE}[info]${NC} $1"; }
success() { echo -e "${GREEN}[done]${NC} $1"; }
warn() { echo -e "${YELLOW}[skip]${NC} $1"; }
error() { echo -e "${RED}[fail]${NC} $1"; }
# ─── Resolve dotfiles directory ──────────────────────────────────────────────
DOTFILES="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKUP_DIR="$HOME/.dotfiles-backup-$(date +%Y%m%d)"
echo ""
echo -e "${BOLD}╔══════════════════════════════════════════════════════╗${NC}"
echo -e "${BOLD}║ Terminal Powerhouse — Catppuccin Mocha Edition ║${NC}"
echo -e "${BOLD}╚══════════════════════════════════════════════════════╝${NC}"
echo ""
# ─── Step 1: Preflight ──────────────────────────────────────────────────────
info "Running preflight checks..."
if [[ "$(uname)" != "Darwin" ]]; then
error "This installer is macOS-only."
exit 1
fi
if ! xcode-select -p &>/dev/null; then
info "Installing Xcode Command Line Tools..."
xcode-select --install
echo "Press any key after Xcode tools finish installing..."
read -n 1 -s
fi
success "Preflight passed"
# ─── Step 2: Homebrew ────────────────────────────────────────────────────────
info "Checking Homebrew..."
if ! command -v brew &>/dev/null; then
info "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
success "Homebrew installed"
else
success "Homebrew already installed"
fi
# ─── Step 3: Install dependencies ────────────────────────────────────────────
info "Installing tools via Brewfile..."
if brew bundle --file="$DOTFILES/Brewfile"; then
success "All tools installed"
else
warn "Some brew packages may have failed — check output above"
fi
# ─── Step 4: Backup existing configs ─────────────────────────────────────────
backup() {
local target="$1"
if [[ -e "$target" ]] && [[ ! -L "$target" ]]; then
mkdir -p "$BACKUP_DIR"
local backup_path="$BACKUP_DIR/$(basename "$target")"
cp -r "$target" "$backup_path"
warn "Backed up $(basename "$target") → $BACKUP_DIR/"
fi
}
info "Backing up existing configs..."
backup "$HOME/.config/ghostty"
backup "$HOME/.config/starship.toml"
backup "$HOME/.zshrc"
backup "$HOME/.gitconfig"
backup "$HOME/.gitignore_global"
backup "$HOME/.ripgreprc"
backup "$HOME/.config/lazygit"
backup "$HOME/.config/atuin"
backup "$HOME/.config/yazi"
backup "$HOME/.config/gh"
backup "$HOME/.config/mise"
if [[ -d "$BACKUP_DIR" ]]; then
success "Backups saved to $BACKUP_DIR/"
else
success "No existing configs to back up"
fi
# ─── Step 5: Create symlinks ─────────────────────────────────────────────────
link() {
local src="$1"
local dst="$2"
# Remove existing (file, symlink, or directory)
if [[ -L "$dst" ]]; then
rm -f "$dst"
elif [[ -e "$dst" ]]; then
rm -rf "$dst"
fi
# Ensure parent directory exists
mkdir -p "$(dirname "$dst")"
ln -sf "$src" "$dst"
success "Linked $(basename "$dst")"
}
info "Creating symlinks..."
# Ghostty (whole directory)
link "$DOTFILES/ghostty" "$HOME/.config/ghostty"
# Starship
link "$DOTFILES/starship/starship.toml" "$HOME/.config/starship.toml"
# Zsh
link "$DOTFILES/zsh/zshrc" "$HOME/.zshrc"
# Git
link "$DOTFILES/git/gitconfig" "$HOME/.gitconfig"
link "$DOTFILES/git/gitignore_global" "$HOME/.gitignore_global"
link "$DOTFILES/git/ripgreprc" "$HOME/.ripgreprc"
# Lazygit
link "$DOTFILES/lazygit" "$HOME/.config/lazygit"
# Atuin (just the config file, not the whole dir — atuin stores data there)
mkdir -p "$HOME/.config/atuin"
link "$DOTFILES/atuin/config.toml" "$HOME/.config/atuin/config.toml"
# Yazi (just the theme, not the whole dir)
mkdir -p "$HOME/.config/yazi"
link "$DOTFILES/yazi/theme.toml" "$HOME/.config/yazi/theme.toml"
# GitHub CLI (just the config)
mkdir -p "$HOME/.config/gh"
link "$DOTFILES/gh/config.yml" "$HOME/.config/gh/config.yml"
# Mise
mkdir -p "$HOME/.config/mise"
link "$DOTFILES/mise/config.toml" "$HOME/.config/mise/config.toml"
# ─── Step 6: Interactive setup ───────────────────────────────────────────────
if [[ ! -f "$HOME/.gitconfig.local" ]]; then
echo ""
info "Setting up git identity..."
echo -n " Your name: "
read -r git_name
echo -n " Your email: "
read -r git_email
cat > "$HOME/.gitconfig.local" <<EOF
[user]
name = $git_name
email = $git_email
EOF
success "Created ~/.gitconfig.local"
else
warn "~/.gitconfig.local already exists"
fi
if [[ ! -f "$HOME/.zshrc.local" ]]; then
cp "$DOTFILES/zsh/zshrc.local.example" "$HOME/.zshrc.local"
success "Created ~/.zshrc.local from template"
else
warn "~/.zshrc.local already exists"
fi
# ─── Step 7: Post-install ────────────────────────────────────────────────────
info "Running post-install steps..."
# Build bat theme cache
if command -v bat &>/dev/null; then
bat cache --build &>/dev/null
success "bat theme cache built"
fi
# Install mise tool versions
if command -v mise &>/dev/null; then
info "Installing mise tool versions (node, python)..."
mise install --yes
success "mise tools installed"
fi
# Set default shell to zsh if needed
if [[ "$SHELL" != */zsh ]]; then
info "Setting default shell to zsh..."
chsh -s "$(which zsh)"
success "Default shell set to zsh"
fi
# ─── Done ────────────────────────────────────────────────────────────────────
echo ""
echo -e "${BOLD}╔══════════════════════════════════════════════════════╗${NC}"
echo -e "${BOLD}║ Installation complete! ║${NC}"
echo -e "${BOLD}╚══════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e " ${GREEN}→${NC} Restart your terminal or run: ${BOLD}exec zsh${NC}"
echo -e " ${GREEN}→${NC} Optional: run ${BOLD}./macos.sh${NC} for power-user macOS defaults"
echo -e " ${GREEN}→${NC} Edit ${BOLD}~/.zshrc.local${NC} for machine-specific overrides"
echo -e " ${GREEN}→${NC} Edit ${BOLD}~/.gitconfig.local${NC} for git identity/signing"
echo ""