-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
141 lines (123 loc) Β· 3.6 KB
/
init.sh
File metadata and controls
141 lines (123 loc) Β· 3.6 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
#!/bin/zsh
# disable Homebrew environment hints
export HOMEBREW_NO_ENV_HINTS=1
# function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# function to print status messages
print_status() {
echo "π $1"
}
# function to print success messages
print_success() {
echo "β
$1"
}
# function to print error messages
print_error() {
echo "β $1"
}
# check and install Xcode Command Line Tools
if ! command_exists xcode-select; then
print_status "Installing Xcode Command Line Tools..."
xcode-select --install
else
print_success "Xcode Command Line Tools are already installed"
fi
# print Xcode Command Line Tools version to confirm installation
if command_exists xcode-select; then
version=$(xcode-select -v | sed 's/xcode-select version //' | sed 's/\.$//')
print_success "xcode-select version: $version"
fi
# check and install Homebrew
if ! command_exists brew; then
print_status "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
print_success "Homebrew is already installed"
fi
# print Homebrew version to confirm installation
if command_exists brew; then
version=$(brew --version | sed 's/Homebrew //')
print_success "brew version: $version"
fi
# function to apply taps
apply_brew_taps() {
local tap_packages=("$@")
for tap in "${tap_packages[@]}"; do
if brew tap | grep "$tap" > /dev/null; then
print_success "Tap $tap is already applied"
else
brew tap "$tap"
fi
done
}
# function to install formulas
install_brew_formulas() {
local formulas=("$@")
for formula in "${formulas[@]}"; do
if brew list --formula | grep "$formula" > /dev/null; then
print_success "Formula $formula is already installed"
else
print_status "Installing package < $formula >"
brew install "$formula"
fi
# Display version of installed formula
if brew list --formula | grep "$formula" > /dev/null; then
version=$(brew info "$formula" | grep -E "$formula:" | awk '{print $4}')
print_success "$formula version: $version"
fi
done
}
# function to install casks
install_brew_casks() {
local casks=("$@")
for cask in "${casks[@]}"; do
if brew list --cask | grep "$cask" > /dev/null; then
print_success "Cask $cask is already installed"
else
print_status "Installing cask < $cask >"
brew install --cask "$cask"
fi
# Display version of installed cask
if brew list --cask | grep "$cask" > /dev/null; then
version=$(brew info --cask "$cask" | grep -E "$cask:" | awk '{print $3}')
print_success "$cask version: $version"
fi
done
}
# apply the taps first
taps=()
apply_brew_taps "${taps[@]}"
# install casks
apps=(cursor docker warp signal notion utm steam)
install_brew_casks "${apps[@]}"
# install formulas
packages=(git curl stow mas jq)
install_brew_formulas "${packages[@]}"
# function to install App Store apps
install_mas_apps() {
local apps=("$@")
for app in "${apps[@]}"; do
if mas list | grep "$app" > /dev/null; then
print_success "App $app is already installed"
else
print_status "Installing app < $app >"
mas install "$app"
fi
done
}
# install App Store apps
mas_apps=(
897283731 # Strongbox Password Manager
1475387142 # Tailscale
1461845568 # Gifox
)
install_mas_apps "${mas_apps[@]}"
# install oh-my-zsh
if [ -d "$HOME/.oh-my-zsh" ]; then
print_success "oh-my-zsh is already installed"
else
print_status "Installing oh-my-zsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi