-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathessential.sh
More file actions
executable file
·53 lines (46 loc) · 1.58 KB
/
essential.sh
File metadata and controls
executable file
·53 lines (46 loc) · 1.58 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
#!/bin/bash
set -euo pipefail
# Create WebPrjcts directory if not exists
mkdir -p ~/WebPrjcts
# Install Xcode Command Line Tools
if ! xcode-select -p &>/dev/null; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install
# Wait for the installation to complete
echo "Waiting for Xcode Command Line Tools to finish installing..."
until xcode-select -p &>/dev/null; do
sleep 5
done
echo "Xcode Command Line Tools installed successfully."
else
echo "Xcode Command Line Tools already installed."
fi
# Switch to Command Line Tools to avoid node-gyp issues
sudo xcode-select --switch /Library/Developer/CommandLineTools
# Install Rosetta 2 (for Apple Silicon Macs)
if [[ $(uname -m) == "arm64" ]]; then
if pkgutil --pkg-info com.apple.pkg.RosettaUpdateAuto >/dev/null 2>&1; then
echo "Rosetta 2 already installed."
else
echo "Installing Rosetta 2..."
softwareupdate --install-rosetta --agree-to-license
fi
fi
# Install Homebrew
if ! command -v brew &>/dev/null; then
echo "Installing Homebrew..."
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Determine the brew prefix based on architecture
if [[ $(uname -m) == "arm64" ]]; then
BREW_PREFIX="/opt/homebrew"
else
BREW_PREFIX="/usr/local"
fi
echo "Adding Homebrew to PATH..."
echo "eval \"$($BREW_PREFIX/bin/brew shellenv)\"" >> ~/.zprofile
else
BREW_PREFIX="$(brew --prefix)"
echo "Homebrew already installed."
fi
# Export Homebrew environment variables for the current shell
eval "$($BREW_PREFIX/bin/brew shellenv)"