-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·143 lines (124 loc) · 4.41 KB
/
setup.sh
File metadata and controls
executable file
·143 lines (124 loc) · 4.41 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
#!/usr/bin/env bash
# Prompt for sudo access upfront to avoid multiple prompts later
sudo -v
# Keep-alive until the script has finished.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Mac software update (commented out if you don't want it)
# updates=$(softwareupdate --list 2>&1)
# if [[ "$updates" != *"No new software available"* ]]; then
# echo "Updates available, installing..."
# sudo softwareupdate --install --all
# else
# echo "No updates available, skipping installation."
# fi
# Xcode installation
xcode-select --install || echo "Xcode command line tools already installed."
# Install Oh My Zsh, zsh-autosuggestions, and Zsh-z if not installed
if ! command -v zsh-autosuggestions &>/dev/null; then
echo "Installing zsh-autosuggestions..."
brew install zsh-autosuggestions || echo "zsh-autosuggestions already installed."
fi
if [ ! -d "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-z" ]; then
echo "Cloning zsh-z plugin..."
git clone https://github.com/agkozak/zsh-z ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-z || echo "zsh-z already cloned."
fi
# Install Homebrew if not installed
if ! command -v brew &>/dev/null; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || echo "Homebrew installation failed."
else
echo "Homebrew is already installed."
fi
# Add Homebrew to path (if not already done)
if ! grep -q 'eval "$(/opt/homebrew/bin/brew shellenv)"' ~/.zprofile; then
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)" || echo "Failed to add Homebrew to path."
else
echo "Homebrew already in path."
fi
brew update || echo "Failed to update Homebrew."
# Install essential non-GUI apps if not already installed
apps=(python starship awscli redis java jq)
for app in "${apps[@]}"; do
if ! brew list "$app" &>/dev/null; then
echo "Installing $app..."
brew install "$app" || echo "Failed to install $app."
else
echo "$app is already installed."
fi
done
# Install npm packages if not already
npm_packages=(np aws-cdk)
for pkg in "${npm_packages[@]}"; do
if ! npm list -g "$pkg" &>/dev/null; then
echo "Installing $pkg..."
npm install -g "$pkg" || echo "Failed to install $pkg."
else
echo "$pkg is already installed."
fi
done
# Fonts installation
fonts=(sfnt2woff sfnt2woff-zopfli woff2)
for font in "${fonts[@]}"; do
if ! brew list "$font" &>/dev/null; then
echo "Installing $font..."
brew install "$font" || echo "Failed to install $font."
else
echo "$font is already installed."
fi
done
# Install essential GUI apps with check for existing installation in /Applications
gui_apps=(
"font-hack-nerd-font"
"warp"
"google-chrome"
"firefox"
"slack"
"numi"
"zoom"
"visual-studio-code"
"maccy"
"gpg-suite"
"flux"
"sublime-text"
"raycast"
"microsoft-outlook"
"postman"
"docker"
)
for app in "${gui_apps[@]}"; do
# Check if the app is already in /Applications or installed by Homebrew
if [ -d "/Applications/$app.app" ] || brew list --cask "$app" &>/dev/null; then
echo "$app is already installed in /Applications or via Homebrew."
else
echo "Installing $app..."
brew install --cask --appdir="/Applications" "$app" || echo "Failed to install $app."
fi
done
# Cleanup
brew cleanup || echo "Failed to cleanup Homebrew."
# Personal folder structure
mkdir -p ~/sites || echo "Failed to create ~/sites."
# Download .zshrc from GitHub
GITHUB_ZSHRC_URL="https://raw.githubusercontent.com/onlyonehas/mac_dev_setup/main/.zshrc"
if ! curl -s $GITHUB_ZSHRC_URL -o ~/.zshrc; then
echo "Failed to download .zshrc."
else
source ~/.zshrc
echo ".zshrc successfully updated."
fi
# Download and configure starship.toml
GITHUB_STARSHIP_URL="https://raw.githubusercontent.com/onlyonehas/mac_dev_setup/main/startship.toml"
mkdir -p ~/.config || echo "Failed to create config directory."
if ! curl -s $GITHUB_STARSHIP_URL -o ~/.config/starship.toml; then
echo "Failed to download starship.toml."
else
echo "starship.toml successfully updated."
fi
# Uncomment below if needed
# brew install --cask --appdir="/Applications" cheatsheet
# brew install --cask --appdir="/Applications" alfred
# brew install remotemobprogramming/brew/mob
# brew upgrade remotemobprogramming/brew/mob
# brew install --cask --appdir="/Applications" 1clipboard
# brew install --cask --appdir="/Applications" sourcetree