-
Notifications
You must be signed in to change notification settings - Fork 644
Expand file tree
/
Copy pathbrew.sh
More file actions
executable file
·216 lines (186 loc) · 6.17 KB
/
brew.sh
File metadata and controls
executable file
·216 lines (186 loc) · 6.17 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
#!/usr/bin/env zsh
# Install Homebrew if it isn't already installed
if ! command -v brew &>/dev/null; then
echo "Homebrew not installed. Installing Homebrew."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Attempt to set up Homebrew PATH automatically for this session
if [ -x "/opt/homebrew/bin/brew" ]; then
# For Apple Silicon Macs
echo "Configuring Homebrew in PATH for Apple Silicon Mac..."
export PATH="/opt/homebrew/bin:$PATH"
fi
else
echo "Homebrew is already installed."
fi
# Verify brew is now accessible
if ! command -v brew &>/dev/null; then
echo "Failed to configure Homebrew in PATH. Please add Homebrew to your PATH manually."
exit 1
fi
# Moving pipx install location for easy reference in VSCode Settings
if [ ! -d "/opt/pipx" ]; then
echo "Creating /opt/pipx and setting up permissions..."
sudo mkdir -p /opt/pipx/{bin,share/man}
sudo chown -R $(whoami):admin /opt/pipx
export PIPX_HOME="/opt/pipx"
export PIPX_BIN_DIR="/opt/pipx/bin"
export PIPX_MAN_DIR="/opt/pipx/share/man"
export PATH="/opt/pipx/bin:$PATH"
else
echo "/opt/pipx already exists. Skipping directory creation."
fi
# Update Homebrew and Upgrade any already-installed formulae and casks
# (brew upgrade has upgraded casks by default since Homebrew 3.2)
brew update
brew upgrade
brew cleanup
# Define an array of packages to install using Homebrew.
packages=(
"python"
"tcl-tk"
"python-tk"
"bash"
"zsh"
"coreutils"
"git"
"fzf"
"tree"
"node"
"uv"
"pipx"
"gemini-cli"
"gh"
"ripgrep"
"dust"
"fd"
"tealdeer"
"ffmpeg"
"imagemagick"
)
# brew install is idempotent — already-installed packages are skipped with a notice.
brew install "${packages[@]}"
# Get the path to Homebrew's zsh
BREW_ZSH="$(brew --prefix)/bin/zsh"
# Check if Homebrew's zsh is already the default shell
if [ "$SHELL" != "$BREW_ZSH" ]; then
echo "Changing default shell to Homebrew zsh"
# Check if Homebrew's zsh is already in allowed shells
if ! grep -Fxq "$BREW_ZSH" /etc/shells; then
echo "Adding Homebrew zsh to allowed shells..."
echo "$BREW_ZSH" | sudo tee -a /etc/shells >/dev/null
fi
# Set the Homebrew zsh as default shell
chsh -s "$BREW_ZSH"
echo "Default shell changed to Homebrew zsh."
else
echo "Homebrew zsh is already the default shell. Skipping configuration."
fi
# Set up fzf key bindings and completion
if [[ ! -f "${HOME}/.fzf.zsh" ]]; then
echo "Setting up fzf shell integration..."
"$(brew --prefix)/opt/fzf/install"
else
echo "fzf shell integration already configured. Skipping configuration."
fi
# Git config name
current_name=$($(brew --prefix)/bin/git config --global --get user.name)
if [ -z "$current_name" ]; then
echo "Please enter your FULL NAME for Git configuration:"
read -r git_user_name
$(brew --prefix)/bin/git config --global user.name "$git_user_name"
echo "Git user.name has been set to $git_user_name"
else
echo "Git user.name is already set to '$current_name'. Skipping configuration."
fi
# Git config email
current_email=$($(brew --prefix)/bin/git config --global --get user.email)
if [ -z "$current_email" ]; then
echo "Please enter your EMAIL for Git configuration:"
read -r git_user_email
$(brew --prefix)/bin/git config --global user.email "$git_user_email"
echo "Git user.email has been set to $git_user_email"
else
echo "Git user.email is already set to '$current_email'. Skipping configuration."
fi
# Github uses "main" as the default branch name
$(brew --prefix)/bin/git config --global init.defaultBranch main
# Check if already authenticated with GitHub to avoid re-authentication prompt
if ! $(brew --prefix)/bin/gh auth status &>/dev/null; then
echo "You will need to authenticate with GitHub. Follow the prompts to login..."
$(brew --prefix)/bin/gh auth login
else
echo "Already authenticated with GitHub. Skipping login."
fi
# Create the tutorial virtual environment I use frequently
$(brew --prefix)/bin/python3 -m venv "${HOME}/tutorial"
# Install Prettier, which I use in VSCode
$(brew --prefix)/bin/npm install --global prettier
# Install ESLint, which I use in VSCode
$(brew --prefix)/bin/npm install --global eslint
# Install DJLint, which I use in VSCode for Django and Jinja2 Template Formatting
$(brew --prefix)/bin/pipx install djlint
# Install Ruff, which I use in VSCode for Python Formatting and Linting
$(brew --prefix)/bin/uv tool install ruff
# Define an array of applications to install using Homebrew Cask.
apps=(
"google-chrome"
"firefox"
"brave-browser"
"visual-studio-code"
"git-credential-manager"
"docker-desktop"
"claude-code"
"codex"
"copilot-cli"
"spotify"
"discord"
"google-drive"
"gimp"
"vlc"
"rectangle"
"postman"
"keyboardcleantool"
)
brew install --cask "${apps[@]}"
# Install fonts. Fonts are now available directly from Homebrew cask
fonts=(
"font-source-code-pro"
"font-lato"
"font-montserrat"
"font-nunito"
"font-open-sans"
"font-oswald"
"font-poppins"
"font-raleway"
"font-roboto"
"font-architects-daughter"
"font-fontawesome"
"font-varela-round"
"font-quicksand"
"font-caveat"
"font-playfair-display"
"font-josefin-sans"
)
brew install --cask "${fonts[@]}"
# Once fonts are installed, import your Terminal Profile
echo "Import your terminal settings..."
echo "Terminal -> Settings -> Profiles -> Import..."
echo "Import from ${HOME}/dotfiles/settings/CMS.terminal"
echo "Press enter to continue..."
read
# Update and clean up again for safe measure
brew update
brew upgrade
brew cleanup
echo "Sign in to Google Chrome. Press enter to continue..."
read
echo "Connect Google Account (System Settings -> Internet Accounts). Press enter to continue..."
read
echo "Sign in to Spotify. Press enter to continue..."
read
echo "Sign in to Discord. Press enter to continue..."
read
echo "Open Rectangle and give it necessary permissions. Press enter to continue..."
read
echo "Import your Rectangle settings located in ~/dotfiles/settings/RectangleConfig.json. Press enter to continue..."
read