-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
199 lines (150 loc) ยท 4.93 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
#!/usr/bin/env zsh
# +---------------------+
# | install xcode tools |
# +---------------------+
print "๐ checking xcode tools are installed..."
if ! xcode-select --print-path &>/dev/null; then
print "๐๏ธ installing xcode command line tools..."
xcode-select --install &>/dev/null
# Wait until the XCode Command Line Tools are installed
until xcode-select --print-path &>/dev/null; do
sleep 10
done
print "โ๏ธ xcode command line tools installed!"
print "โ ๏ธ Agree with the xcode command line tools licence:"
sudo xcodebuild -license
fi
# +-------------------+
# | configure ZDOTDIR |
# +-------------------+
# Set the desired configuration line
zdotdir_line='export ZDOTDIR="$HOME/.config/zsh"'
# Check if /etc/zshenv exists
if [[ -f "/etc/zshenv" ]]; then
if ! grep -qF "$zdotdir_line" "/etc/zshenv"; then
print "$zdotdir_line" | sudo tee -a "/etc/zshenv" >/dev/null
print "โ๏ธ appended '$zdotdir_line' to '/etc/zshenv/'"
fi
else
print "$zdotdir_line" | sudo tee "/etc/zshenv" >/dev/null
print "โ๏ธ created '/etc/zshenv' and appended the '$zdotdir_line' line."
fi
# +--------------+
# | install brew |
# +--------------+
print "๐ Checking homebrew is installed..."
local brew_bin
brew_bin=$(which brew) 2>&1 >/dev/null
if [[ $? != 0 ]]; then
print "๐๏ธ installing homebrew..."
# has to run in bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [[ $? != 0 ]]; then
print "๐จ unable to install homebrew, script $0 abort!"
exit 2
fi
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# +--------------+
# | set XDG dirs |
# +--------------+
# see https://wiki.archlinux.org/title/XDG_Base_Directory
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
# +----------------+
# | clone dotfiles |
# +----------------+
if ! [[ -d "$HOME/.config" ]]; then
git clone "https://github.com/baggiponte/dotfiles" "$HOME/.config"
else
read -r -p "โ ๏ธ '$HOME/.config' already exists. Replace dotfiles? (contents of '$HOME/.config' will not be deleted) [y/N]" response
if [[ $response =$HOME (y|yes|Y) ]]; then
mv "$HOME/.config" "$HOME/.config.bak"
print "โ๏ธ moved old configs to '$HOME/.config.bak'"
git clone "https://github.com/baggiponte/dotfiles" "$HOME/.config"
else
print "โ ๏ธ did not clone dotfiles: this script might fail if a binary is not found"
fi
fi
ln -s "$HOME/.config/.gitconfig" "$HOME/.gitconfig"
ln -s "$HOME/Library/Mobile Documents/com~apple~CloudDocs/" "icloud"
# +----------------------+
# | install dependencies |
# +----------------------+
read -r -p "โ install dependencies from Brewfile? [y/N]" response
if [[ $response =$HOME (y|yes|Y) ]]; then
brew bundle --file="$HOME/.config/Brewfile"
if command -v "docker-compose" &> /dev/null; then
if ! [[ -d "$HOME/.docker/cli-plugins" ]]; then
mkdir -p "$HOME/.docker/cli-plugins"
fi
ln -sfn "$(brew --prefix)/opt/docker-compose/bin/docker-compose" "$HOME/.docker/cli-plugins/docker-compose"
if ! [[ -d "$HOME/.docker" ]]; then
mkdir -p "$HOME/.docker"
fi
cat <<- EOF > $HOME/.docker/config.json
{
"cliPluginsExtraDirs": [
"/opt/homebrew/lib/docker/cli-plugins"
]
}
EOF
fi
if command -v "docker-buildx" &> /dev/null; then
if ! [[ -d "$HOME/.docker/cli-plugins" ]]; then
mkdir -p "$HOME/.docker/cli-plugins"
fi
ln -sfn "$(brew --prefix)/opt/docker-compose/bin/docker-buildx" "$HOME/.docker/cli-plugins/docker-buildx"
fi
else
print "โ ๏ธ skipped brew package installs"
fi
# +---------------------+
# | install python CLIs |
# +---------------------+
print "Install uv (https://github.com/astral-sh/uv#uv)"
curl -LsSf https://astral.sh/uv/install.sh | sh
versions=(
"3.13"
"3.12"
"3.11"
"3.10"
"3.9"
)
safe_version="${versions[1]}"
for version in "${versions[@]}"; do
uv python install -- "$version"
done
libs=(
"argcomplete"
"jupytext"
)
for lib in "${libs[@]}"; do
uv tool install --upgrade --python="$safe_version" -- "$lib"
done
uv tool install --upgrade --python="$safe_version" --with pre-commit-uv -- pre-commit
mkdir -p "$HOME/Library/Application Support/pdm"
ln -s "$XDG_CONFIG_HOME/pdm/config.toml" "$HOME/Library/Application Support/pdm/config.toml"
# +--------------+
# | install rust |
# +--------------+
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
export CARGO_HOME="$XDG_DATA_HOME/cargo"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
for version in "stable"; do
rustup install "$version"
rustup component add rust-analyzer --toolchain="$version"
done
# +--------------+
# | install nvim |
# +--------------+
bob install latest
bob use latest
# +-------------------+
# | compile bat theme |
# +-------------------+
if command -v bat; then
bat cache --build
fi