Skip to content

Commit 0ac8991

Browse files
committed
macos: fixup setup script
1 parent a0fd229 commit 0ac8991

File tree

1 file changed

+59
-7
lines changed

1 file changed

+59
-7
lines changed

setup-macos.sh

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,51 @@ gpg_encryption_subkey=0x79C70BBE4865D828
55

66
base_path=$PWD
77
data_path="$base_path"/data
8+
git_submodule_path="$base_path"/.git_submodules
9+
10+
exit_setup() {
11+
rv=$?
12+
printf "\n\nExiting setup...\n"
13+
exit $rv
14+
}
15+
16+
set -euo pipefail
17+
trap 'exit_setup' ERR INT
18+
symlink() {
19+
if [[ -e "${2}" ]]; then
20+
if [[ ! -L "${2}" ]]; then
21+
echo "${2} already exists and is an irregular type. Check manually whether this is safe to replace with ${1}."
22+
return 1
23+
fi
24+
25+
echo "Removing existing symlink at ${2}"
26+
rmrf "${2}" || {
27+
echo "failed to remove old symlink: ${2}"
28+
return 1
29+
}
30+
fi
31+
32+
# Stow only supports relative symlinks
33+
ln -s "${1}" "${2}" || {
34+
echo "failed to symlink: ${1} to ${2}"
35+
return 1
36+
}
37+
}
38+
39+
rmrf() {
40+
rm -rf "${1}" || {
41+
echo "failed to recursively remove ${1}"
42+
return 1
43+
}
44+
}
845

946
declare -a brew_pkgs=(
1047
bat
1148
font-hack-nerd-font
1249
gnupg
1350
go
1451
helix
52+
mpv
1553
neovim
1654
node
1755
npm
@@ -34,7 +72,7 @@ brew install "${brew_pkgs[@]}" || {
3472
echo "failed to install brew packages"
3573
}
3674

37-
git submodule update --init --remote --progress omz/.oh-my-zsh/themes/powerlevel10k || {
75+
git submodule update --init --recursive --remote --progress || {
3876
echo "failed to update git submodules"
3977
exit 1
4078
}
@@ -53,12 +91,14 @@ echo "Setting up GPG/SSH"
5391
gpg --list-keys >/dev/null
5492

5593
declare -a mk_dirs=(
56-
~/.cargo
5794
~/.cargo
5895
~/.config
5996
~/.continue
6097
~/.local/bin
98+
~/.local/share
6199
~/.ssh
100+
~/Library/KeyBindings
101+
~/Library/LaunchAgents
62102
)
63103

64104
for mk_dir in "${mk_dirs[@]}"; do
@@ -98,6 +138,22 @@ cp -v "$data_path"/gpg/gpg-agent.conf "$base_path"/gpg/.gnupg/gpg-agent.conf ||
98138
}
99139
echo "pinentry-program $HOME/.local/bin/pinentry-auto" | tee -a "$HOME"/.gnupg/gpg-agent.conf
100140

141+
# Fix for spacing breaking the space delimited tuples
142+
mv "${git_submodule_path}"/catppuccin-bat/themes/Catppuccin\ Mocha.tmTheme "${git_submodule_path}"/catppuccin-bat/themes/Catppuccin-Mocha.tmTheme || {
143+
echo "failed to move catppuccin-bat theme"
144+
exit 1
145+
}
146+
147+
declare -a symlink_paths_tuples=(
148+
"${git_submodule_path}/alacritty-theme/themes ${base_path}/alacritty/.config/alacritty/themes"
149+
"${git_submodule_path}/catppuccin-bat/themes/Catppuccin-Mocha.tmTheme ${base_path}/bat/.config/bat/themes/Catppuccin-Mocha.tmTheme"
150+
"${git_submodule_path}/catppuccin-helix/themes/default/catppuccin_mocha.toml ${base_path}/helix/.config/helix/themes/catppuccin_mocha.toml"
151+
)
152+
for symlink_paths_tuple in "${symlink_paths_tuples[@]}"; do
153+
read -ra symlink_paths <<<"$symlink_paths_tuple"
154+
symlink "${symlink_paths[0]}" "${symlink_paths[1]}"
155+
done
156+
101157
stow_config() {
102158
stow -v "$1" || {
103159
echo "Failed to stow ${1} config"
@@ -109,6 +165,7 @@ declare -a stow_dirs_setup=(
109165
bash
110166
git
111167
gpg
168+
macos
112169
ssh
113170
stow
114171
zsh
@@ -119,11 +176,6 @@ for stow_dir in "${stow_dirs_setup[@]}"; do
119176
stow_config "$stow_dir"
120177
done
121178

122-
rsync --progress -ruacv -- macos/* "$HOME"/ || {
123-
echo "failed to rsync macos config"
124-
return 1
125-
}
126-
127179
declare -a launch_agents=(
128180
"$HOME"/Library/LaunchAgents/gnupg.gpg-agent.plist
129181
"$HOME"/Library/LaunchAgents/gnupg.gpg-agent-symlink.plist

0 commit comments

Comments
 (0)