-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
Β·389 lines (341 loc) Β· 13 KB
/
setup.sh
File metadata and controls
executable file
Β·389 lines (341 loc) Β· 13 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# Don't exit on error - we want to continue and report all errors at the end
set +e
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Error tracking
declare -a ERRORS=()
declare -a WARNINGS=()
CURRENT_STEP=""
# Status functions
print_step() {
CURRENT_STEP="$1"
echo -e "${BLUE}π΅ $1${NC}"
}
print_success() {
echo -e "${GREEN}β
$1${NC}"
}
print_info() {
echo -e "${CYAN}βΉοΈ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}β οΈ $1${NC}"
WARNINGS+=("$1")
}
print_error() {
echo -e "${RED}β $1${NC}"
ERRORS+=("$CURRENT_STEP: $1")
}
# Run command and track errors
run_cmd() {
"$@"
local status=$?
if [ $status -ne 0 ]; then
print_error "Command failed with exit code $status: $*"
return $status
fi
return 0
}
# Check last command status and report error if failed
check_status() {
local status=$?
local msg="$1"
if [ $status -ne 0 ]; then
print_error "$msg (exit code: $status)"
return 1
fi
return 0
}
echo -e "${PURPLE}π Starting dotfiles setup...${NC}"
echo -e "${CYAN}π Script path: $SCRIPTPATH${NC}"
echo ""
print_step "Setting up iTerm2 preferences..."
if [ -d "~/Library/Preferences/com.googlecode.iterm2.plist" ];
then
rm ~/Library/Preferences/com.googlecode.iterm2.plist
ln -s $SCRIPTPATH/com.googlecode.iterm2.plist ~/Library/Preferences/com.googlecode.iterm2.plist
print_success "iTerm2 preferences linked"
else
print_info "iTerm2 preferences directory not found, skipping"
fi
print_step "Setting up Xcode preferences..."
if [ -d "~/Library/Developer/Xcode/UserData" ];
then
rm -rf ~/Library/Developer/Xcode/UserData
ln -s $SCRIPTPATH/Xcode/UserData ~/Library/Developer/Xcode/UserData
print_success "Xcode preferences linked"
else
print_info "Xcode UserData directory not found, skipping"
fi
print_step "Setting up Vim configuration..."
mv ~/.vimrc ~/.vimrc-bak || true
ln -s $SCRIPTPATH/.vimrc ~/.vimrc
print_success "Vim configuration linked"
print_step "Setting up Git configuration..."
mv ~/.gitconfig ~/.gitconfig.bak || true
ln -s $SCRIPTPATH/gitfiles/.gitconfig ~/.gitconfig
print_success "Git configuration linked"
print_step "Installing Vim Pathogen..."
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
if [ $? -eq 0 ]; then
print_success "Pathogen installed"
else
print_error "Failed to install Pathogen"
fi
print_step "Installing Vim plugins..."
cd ~/.vim/bundle
if [ ! -d "./vim-bundler" ];
then
print_info "Cloning vim-bundler..."
git clone https://github.com/tpope/vim-bundler.git
print_success "vim-bundler installed"
else
print_info "vim-bundler already installed"
fi;
if [ ! -d "./Vundle.vim" ];
then
print_info "Cloning Vundle.vim..."
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
print_success "Vundle.vim installed"
else
print_info "Vundle.vim already installed"
fi
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
echo ""
print_step "π§ Detected Linux system - starting Linux-specific setup..."
print_step "Removing old Vim packages..."
sudo apt-get remove --yes vim vim-runtime gvim vim-tiny vim-common vim-gui-common vim-nox
print_success "Old Vim packages removed"
print_step "Installing apt packages..."
cat $SCRIPTPATH/apt-packages.txt | xargs sudo apt-get --yes --force-yes install
if [ $? -eq 0 ]; then
print_success "APT packages installed"
else
print_error "Failed to install some APT packages"
fi
print_step "Compiling Vim from source..."
cd ~
if git clone https://github.com/vim/vim.git && cd vim; then
print_info "Configuring Vim..."
if ./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp \
--enable-pythoninterp \
--enable-python3interp \
--with-python3-config-dir=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu \
--with-python3-config-dir=/usr/lib/python3.5/config \
--enable-perlinterp \
--enable-luainterp \
--enable-gui=gtk2 --enable-cscope --prefix=/usr; then
print_info "Building Vim (this may take a while)..."
if make VIMRUNTIMEDIR=/usr/share/vim/vim74; then
print_info "Installing Vim..."
if sudo make install; then
cd ~
sudo checkinstall || print_warning "checkinstall failed, but Vim was installed"
print_success "Vim compiled and installed"
else
print_error "Failed to install Vim"
fi
else
print_error "Failed to build Vim"
fi
else
print_error "Failed to configure Vim"
fi
else
print_error "Failed to clone Vim repository"
fi
print_step "Configuring Vim as default editor..."
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
sudo update-alternatives --set editor /usr/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1
sudo update-alternatives --set vi /usr/bin/vim
print_success "Vim set as default editor"
print_step "Configuring ZSH as default shell..."
TEMP_PAM=`mktemp`; echo "auth sufficient pam_wheel.so trust group=chsh" | cat - /etc/pam.d/chsh > $TEMP_PAM && sudo mv $TEMP_PAM /etc/pam.d/chsh
sudo groupadd chsh
usermod -a -G chsh `whoami`
chsh -s `which zsh`
print_success "ZSH configured as default shell"
print_step "Setting up Docker..."
if sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D; then
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list
sudo apt-cache policy docker-engine
sudo apt-get update
print_info "Installing Docker engine..."
if sudo apt-get install --yes docker-engine; then
sudo usermod -aG docker ubuntu
sudo service docker start
print_success "Docker installed and started"
else
print_error "Failed to install Docker engine"
fi
else
print_error "Failed to add Docker repository key"
fi
elif [[ "$unamestr" == 'Darwin' ]]; then
echo ""
print_step "π Detected macOS system - starting macOS-specific setup..."
print_step "Checking for Homebrew..."
if ! brew -v 2>/dev/null; then
print_info "Installing Homebrew..."
if /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"; then
print_success "Homebrew installed"
else
print_error "Failed to install Homebrew"
fi
else
print_success "Homebrew already installed"
fi
print_step "Setting up Oh-My-Zsh..."
if [ ! -d "$HOME/.oh-my-zsh" ];
then
print_info "Installing Oh-My-Zsh..."
if wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh; then
print_success "Oh-My-Zsh installed"
else
print_error "Failed to install Oh-My-Zsh"
fi
else
print_info "Oh-My-Zsh already installed"
fi
print_step "Configuring ZSH as default shell..."
if sudo chsh -s `which zsh` `whoami`; then
print_success "ZSH configured"
else
print_error "Failed to configure ZSH as default shell"
fi
print_step "Installing Homebrew packages..."
brew install cmake \
wget ruby-build \
vim tree \
rbenv fzf forgit pipx python@3
if [ $? -eq 0 ]; then
print_success "Homebrew packages installed"
else
print_error "Failed to install some Homebrew packages"
fi
print_step "Checking for Xcode Command Line Tools..."
if ! xcode-select -v 2>/dev/null; then
print_info "Installing Xcode Command Line Tools..."
if sudo xcode-select --install; then
print_success "Xcode Command Line Tools installed"
else
print_warning "Xcode Command Line Tools installation may require manual intervention"
fi
else
print_success "Xcode Command Line Tools already installed"
fi
fi
print_step "Installing fzf key bindings and fuzzy completion..."
yes | $(brew --prefix)/opt/fzf/install
if [ $? -eq 0 ]; then
print_success "fzf key bindings installed"
else
print_error "Failed to install fzf key bindings"
fi
print_step "Installing Vim plugins with Vundle..."
vim -c BundleInstall -c quitall
if [ $? -eq 0 ]; then
print_success "Vim plugins installed"
else
print_error "Failed to install Vim plugins"
fi
print_step "Building YouCompleteMe..."
if [ -d ~/.vim/bundle/YouCompleteMe ]; then
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
if [ $? -eq 0 ]; then
print_success "YouCompleteMe built"
else
print_error "Failed to build YouCompleteMe"
fi
else
print_warning "YouCompleteMe directory not found, skipping build"
fi
print_step "Installing vimpager..."
VIMPAGER_DIR=`mktemp -d`
cd "$VIMPAGER_DIR"
if git clone https://github.com/rkitover/vimpager && cd vimpager && sudo make install; then
print_success "vimpager installed"
else
print_error "Failed to install vimpager"
fi
print_step "Installing Python virtualenvwrapper..."
sudo pip3 install virtualenvwrapper
if [ $? -eq 0 ]; then
print_success "virtualenvwrapper installed"
else
print_error "Failed to install virtualenvwrapper"
fi
print_step "Setting up shell profiles..."
mv ~/.bash_profile ~/.bash_profile.bak || true
ln -s $SCRIPTPATH/.zshrc ~/.bash_profile
print_info "bash_profile linked"
print_step "Installing Cursor..."
curl https://cursor.com/install -fsS | bash
if [ $? -eq 0 ]; then
print_success "Cursor installed"
else
print_error "Failed to install Cursor"
fi
mv ~/.zshrc ~/.zshrc.bak || true
ln -s $SCRIPTPATH/.zshrc ~/.zshrc
print_success "Shell profiles configured"
cd -
echo ""
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
# Display summary
if [ ${#ERRORS[@]} -eq 0 ]; then
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${GREEN}β β${NC}"
echo -e "${GREEN}β π Setup completed successfully! π β${NC}"
echo -e "${GREEN}β β${NC}"
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
else
echo -e "${YELLOW}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${YELLOW}β β${NC}"
echo -e "${YELLOW}β β οΈ Setup completed with errors β οΈ β${NC}"
echo -e "${YELLOW}β β${NC}"
echo -e "${YELLOW}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
fi
echo ""
# Show warnings if any
if [ ${#WARNINGS[@]} -gt 0 ]; then
echo -e "${YELLOW}β οΈ WARNINGS (${#WARNINGS[@]}):${NC}"
echo -e "${YELLOW}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
for warning in "${WARNINGS[@]}"; do
echo -e "${YELLOW} β’ $warning${NC}"
done
echo ""
fi
# Show errors if any
if [ ${#ERRORS[@]} -gt 0 ]; then
echo -e "${RED}β ERRORS (${#ERRORS[@]}):${NC}"
echo -e "${RED}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
for error in "${ERRORS[@]}"; do
echo -e "${RED} β’ $error${NC}"
done
echo ""
echo -e "${YELLOW}π‘ Please review and fix the errors above, then re-run this script.${NC}"
echo ""
else
print_info "Please restart your terminal or run 'source ~/.zshrc' to apply changes"
echo ""
fi
# Exit with error code if there were errors
if [ ${#ERRORS[@]} -gt 0 ]; then
exit 1
else
exit 0
fi