-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·273 lines (221 loc) · 6.93 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·273 lines (221 loc) · 6.93 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
#!/bin/bash
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Print message with color
print_message() {
echo -e "${GREEN}==>${NC} $1"
}
print_warning() {
echo -e "${YELLOW}==>${NC} $1"
}
# Check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Install core dependencies based on OS
install_core_dependencies() {
if [[ "$OSTYPE" == "darwin"* ]]; then
print_message "Installing core dependencies for macOS..."
# Check if Homebrew is installed
if ! command_exists brew; then
print_message "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
print_message "Homebrew already installed, updating..."
brew update
fi
# Install GNU stow
if ! command_exists stow; then
print_message "Installing GNU stow..."
brew install stow
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
print_message "Installing core dependencies for Ubuntu..."
# Update package lists
print_message "Updating package lists..."
sudo apt update
# Install GNU stow
if ! command_exists stow; then
print_message "Installing GNU stow..."
sudo apt install -y stow
fi
else
print_warning "Unsupported OS: $OSTYPE"
exit 1
fi
}
# Install common tools for both macOS and Ubuntu
install_common_tools() {
print_message "Installing common tools..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS installations using Homebrew
# Terminal utilities
print_message "Installing terminal utilities..."
brew install nvim starship zoxide fzf eza bat fastfetch lolcat git
brew install zsh-syntax-highlighting zsh-autosuggestions
# Programming environments
if ! command_exists pyenv; then
print_message "Installing pyenv..."
brew install pyenv pyenv-virtualenv
fi
# NVM for Node.js
if [ ! -d "$HOME/.nvm" ]; then
print_message "Installing nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
fi
# AI tools
print_message "Installing AI tools..."
brew install ollama
pip install aider-chat
pip install claude-cli
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Ubuntu installations
# Install build essentials and other dependencies
print_message "Installing build essentials and dependencies..."
sudo apt install -y build-essential curl wget git zsh
# Install Neovim
if ! command_exists nvim; then
print_message "Installing Neovim..."
sudo apt install -y neovim
fi
# Install Starship prompt
if ! command_exists starship; then
print_message "Installing Starship prompt..."
curl -sS https://starship.rs/install.sh | sh
fi
# Install Zoxide
if ! command_exists zoxide; then
print_message "Installing Zoxide..."
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
fi
# Install FZF
if [ ! -d "$HOME/.fzf" ]; then
print_message "Installing FZF..."
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --all
fi
# Install eza (modern ls replacement)
if ! command_exists eza; then
print_message "Installing eza..."
sudo apt install -y eza || {
# If not available in repositories, try cargo install
if ! command_exists cargo; then
print_message "Installing Rust for eza..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
fi
cargo install eza
}
fi
# Install bat
if ! command_exists bat; then
print_message "Installing bat..."
sudo apt install -y bat || sudo apt install -y batcat
fi
# Install fastfetch
if ! command_exists fastfetch; then
print_message "Installing fastfetch..."
sudo apt install -y fastfetch || {
print_warning "fastfetch not available in repositories, skipping..."
}
fi
# Install lolcat
if ! command_exists lolcat; then
print_message "Installing lolcat..."
sudo apt install -y lolcat || sudo gem install lolcat
fi
# Install ZSH plugins
print_message "Installing ZSH plugins..."
sudo apt install -y zsh-syntax-highlighting zsh-autosuggestions
# Antigen
if [ ! -f "$HOME/antigen.zsh" ]; then
print_message "Installing Antigen..."
curl -L git.io/antigen > ~/antigen.zsh
fi
# Pyenv
if ! command_exists pyenv; then
print_message "Installing pyenv..."
curl https://pyenv.run | bash
fi
# NVM
if [ ! -d "$HOME/.nvm" ]; then
print_message "Installing nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
fi
# AI tools
print_message "Installing AI tools..."
curl https://ollama.ai/install.sh | sh
pip install aider-chat
pip install claude-cli
fi
}
# Install macOS specific tools
install_macos_tools() {
if [[ "$OSTYPE" != "darwin"* ]]; then
return
fi
print_message "Installing macOS specific tools..."
# PostgreSQL
brew install postgresql@16
# Asciiquarium
brew install asciiquarium
# SDKMAN
if [ ! -d "$HOME/.sdkman" ]; then
print_message "Installing SDKMAN..."
curl -s "https://get.sdkman.io" | bash
fi
}
# Install Ubuntu specific tools
install_ubuntu_tools() {
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
return
fi
print_message "Installing Ubuntu specific tools..."
# Add any Ubuntu-specific tools here
}
# Create necessary config directories
create_config_dirs() {
print_message "Creating config directories..."
mkdir -p "$HOME/.config/nvim/logo"
mkdir -p "$HOME/.config/eza"
mkdir -p "$HOME/.config/bat/themes"
mkdir -p "$HOME/.cache/zsh"
}
# Setup dotfiles with stow
setup_dotfiles() {
print_message "Setting up dotfiles with stow..."
# Check if we're in the dotfiles directory
if [ ! -f "$(pwd)/README.md" ] || ! grep -q "Dot files" "$(pwd)/README.md"; then
print_warning "Please run this script from the dotfiles directory"
exit 1
fi
# Backup existing configs
if [ -f "$HOME/.zshrc" ]; then
print_message "Backing up existing .zshrc..."
mv "$HOME/.zshrc" "$HOME/.zshrc.backup"
fi
# Create symlinks with stow
print_message "Creating symlinks with stow..."
stow .
print_message "Dotfiles installation complete!"
print_message "Please log out and log back in or run 'source ~/.zshrc' to apply changes."
}
# Main function
main() {
print_message "Starting dotfiles setup..."
install_core_dependencies
install_common_tools
if [[ "$OSTYPE" == "darwin"* ]]; then
install_macos_tools
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
install_ubuntu_tools
fi
create_config_dirs
setup_dotfiles
print_message "Setup complete! 🎉"
}
# Run the script
main