-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
Β·215 lines (171 loc) Β· 5.81 KB
/
install.sh
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
#!/bin/bash
# A utility script to set up a new macOS environment
set -euo pipefail
echo -e "\nπ The World Changed! Beginning MacOS setup...\n"
# Ask for user inputs at the beginning
read -r -p "ο£Ώ Would you like to set macOS preferences now? (y/N): " macos_preferences_confirm
ZSHHOME="$HOME/dotfiles/zsh"
# Function to create directories
create_dirs() {
echo "π Creating directories..."
local dirs=(
"$HOME/Codes"
"$HOME/Documents/Screenshots"
"$HOME/Downloads/Torrents"
)
for dir in "${dirs[@]}"; do
mkdir -p "$dir"
echo "Created $dir"
done
}
# Function to install Xcode Command Line Tools
install_xcode_tools() {
echo "π Installing Xcode Command Line Tools..."
if ! xcode-select --print-path &>/dev/null; then
xcode-select --install &>/dev/null
until xcode-select --print-path &>/dev/null; do
sleep 5
done
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
else
echo "π©» Xcode Command Line Tools already installed."
fi
}
# Function to install Homebrew and packages
install_brew() {
echo "πΊ Installing Homebrew and packages..."
if ! command -v brew &>/dev/null; then
export HOMEBREW_NO_INSTALL_FROM_API=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
echo "πΊ Updating Homebrew..."
brew update --force
echo "πΊ Installing packages..."
brew bundle --file="$HOME/dotfiles/Brewfile"
}
# Function to set macOS preferences
set_macos_preferences() {
if [[ "$macos_preferences_confirm" =~ ^[yY](es)?$ ]]; then
echo "ο£Ώ Setting macOS preferences..."
source "$HOME/dotfiles/macos/.macos"
else
echo "ο£Ώ Skipping macOS preferences setup."
fi
}
# Function to configure Node and Bun
configure_node() {
echo "π¦ Configuring Node..."
npm install -g n &>/dev/null
curl -fsSL https://bun.sh/install | bash
echo "π Baked bun -v$($HOME/.bun/bin/bun --version)"
}
# Function to configure Python
configure_python() {
echo "π Configuring Rye: Cargo for Python"
if ! command -v rye &>/dev/null; then
echo "π Installing Rye"
curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION="--yes" bash
source "$HOME/.rye/env"
rye self completion -s zsh >>~/.zfunc/_rye
rye config --set-bool behavior.global-python=true
rye config --set-bool behavior.use-uv=true
else
echo "πΊ Updating Rye..."
rye self update
fi
}
# Function to setup Jupyter Lab environment
setup_jupyter_lab() {
echo "πͺ Setting up Jupyter Lab environment in Codes/lab..."
mkdir -p "$HOME/Codes/lab"
cd "$HOME/Codes/lab"
# Check if virtual environment directory exists
if [ ! -d ".venv" ]; then
echo "πͺ Creating virtual environment..."
uv venv .venv
fi
# Activate the virtual environment
source .venv/bin/activate
# Check if Jupyter Lab is installed
if ! pip freeze | grep jupyterlab &>/dev/null; then
echo "πͺ Installing Jupyter Lab..."
uv pip install jupyterlab jupyterlab-dash
else
echo "πͺ Jupyter Lab is already installed. Upgrading..."
uv pip install --upgrade jupyterlab jupyterlab-dash
fi
# Deactivate the virtual environment
deactivate
echo "πͺ Jupyter Lab setup complete! π"
echo "πͺ Use 'jupyterit' to start and 'jupyterkill' to stop Jupyter Lab."
# Back to the original directory
cd - || exit
}
# Function to install tmux plugin manager
install_tmux_plugins() {
local folder="$HOME/.tmux/plugins/tpm"
local url="https://github.com/tmux-plugins/tpm"
[ -d "$folder" ] || git clone "$url" "$folder"
}
# Function to install Yazi themes
install_yazi_themes() {
local folder="$HOME/.config/yazi/flavors"
local url="https://github.com/yazi-rs/flavors.git"
[ -d "$folder" ] || git clone "$url" "$folder"
}
# Function for additional setups
setup_utils() {
# Aliases help
chmod +x "$ZSHHOME/.alias_help.sh"
# Install git large files
git lfs install
# Productive laziness
# LLM
rye tools list | grep -q "^llm" && rye tools uninstall llm
rye tools install llm
llm --system 'Reply with linux terminal commands only, no extra information' --save cmd
llm --system 'Reply with neovim commands only, no extra infromation' --save nvim
# Aider
rye tools list | grep -q "^aider" && rye tools uninstall aider-chat
rye tools install aider-chat
}
# Function to create Python virtual environments
create_virtualenvs() {
echo "π Creating Python Virtual Environments..."
local envs=(
"$HOME/.virtualenvs/neovim|pynvim"
"$HOME/.virtualenvs/debugpy|pynvim debugpy"
)
mkdir -p "$HOME/.virtualenvs"
for env in "${envs[@]}"; do
IFS='|' read -r dir packages <<<"$env"
if [ ! -d "$dir" ]; then
python -m venv "$dir" &>/dev/null
fi
"$dir/bin/pip" install --upgrade pip &>/dev/null
"$dir/bin/pip" install --upgrade $packages &>/dev/null
done
echo "π₯ Virtual environments and π¦ packages installed."
}
# Function to use GNU Stow to manage dotfiles
stow_dotfiles() {
echo "π Stowing dotfiles..."
stow -d "$HOME/dotfiles" -t "$HOME" alacritty fzf git nvim sesh skhd starship tmux vim yabai zsh yazi
}
# Main setup sequence
create_dirs
install_xcode_tools
set_macos_preferences
install_brew
configure_node
configure_python
setup_jupyter_lab
create_virtualenvs
install_tmux_plugins
install_yazi_themes
setup_utils
stow_dotfiles
echo "π¦ The World is restored. Setup completed successfully!"