-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·115 lines (97 loc) · 3.41 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·115 lines (97 loc) · 3.41 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
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Helper functions
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're on macOS
if [[ "$OSTYPE" != "darwin"* ]]; then
print_error "This script is designed for macOS only"
exit 1
fi
print_info "Starting dotfiles installation for macOS..."
# Install Homebrew if not present
if ! command -v brew >/dev/null 2>&1; then
print_info "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add Homebrew to PATH for the rest of this script
if [[ -d "/opt/homebrew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -d "/usr/local/Homebrew" ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
print_success "Homebrew installed successfully"
else
print_info "Homebrew already installed"
fi
# Install chezmoi first (needed for dotfiles installation)
if ! command -v chezmoi >/dev/null 2>&1; then
print_info "Installing chezmoi..."
brew install chezmoi
print_success "chezmoi installed successfully"
else
print_info "chezmoi already installed"
fi
# Install all dependencies from Brewfile
print_info "Installing dependencies from Brewfile..."
if brew bundle --file="$HOME/dotfiles/Brewfile"; then
print_success "All dependencies installed successfully"
else
print_warning "Some dependencies may have failed to install. Continuing..."
fi
# Point chezmoi at this checkout as its source dir. --source only affects this
# one invocation and is not persisted, so write it to chezmoi.toml directly --
# otherwise every later plain `chezmoi apply` falls back to the default source
# dir (~/.local/share/chezmoi) and fails outright.
print_info "Installing dotfiles..."
mkdir -p "$HOME/.config/chezmoi"
cat > "$HOME/.config/chezmoi/chezmoi.toml" <<EOF
sourceDir = "$HOME/dotfiles"
EOF
if chezmoi apply -v; then
print_success "Dotfiles installed successfully"
else
print_error "Failed to install dotfiles"
exit 1
fi
# Change shell to zsh if not already
if [[ "$SHELL" != *"zsh"* ]]; then
print_info "Changing shell to zsh..."
if command -v zsh >/dev/null 2>&1; then
sudo chsh -s "$(which zsh)" "$USER"
print_success "Shell changed to zsh"
print_warning "Please restart your terminal or run 'exec zsh' to use the new shell"
else
print_error "zsh not found. Please install zsh manually."
fi
else
print_info "Shell is already zsh"
fi
# Setup 1Password SSH agent if 1Password is installed
if [[ -d "/Applications/1Password.app" ]]; then
print_info "1Password detected - SSH agent should be configured in 1Password settings"
print_info "Go to 1Password → Settings → Developer → Use the SSH agent"
else
print_warning "1Password not found. SSH signing may not work until 1Password is installed and configured"
fi
print_success "Dotfiles installation complete!"
print_info "Next steps:"
echo " 1. Restart your terminal or run 'exec zsh'"
echo " 2. Configure 1Password SSH agent if not already done"
echo " 3. Run 'chezmoi apply' anytime you update your dotfiles"
echo " 4. Run 'brew bundle' to install new packages added to Brewfile"