Skip to content

Commit

Permalink
macos: fixup setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr committed Jan 6, 2025
1 parent a0fd229 commit 7006f4b
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions setup-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,36 @@ gpg_encryption_subkey=0x79C70BBE4865D828

base_path=$PWD
data_path="$base_path"/data
git_submodule_path="$base_path"/.git_submodules

symlink() {
if [[ -e "${2}" ]]; then
if [[ ! -L "${2}" ]]; then
echo "${2} already exists and is an irregular type. Check manually whether this is safe to replace with ${1}."
return 1
fi

echo "Removing existing symlink at ${2}"
rmrf "${2}" || {
echo "failed to remove old symlink: ${2}"
return 1
}
fi

# Stow only supports relative symlinks
ln -s "${1}" "${2}" || {
echo "failed to symlink: ${1} to ${2}"
return 1
}
}

declare -a brew_pkgs=(
bat
font-hack-nerd-font
gnupg
go
helix
mpv
neovim
node
npm
Expand All @@ -34,7 +57,7 @@ brew install "${brew_pkgs[@]}" || {
echo "failed to install brew packages"
}

git submodule update --init --remote --progress omz/.oh-my-zsh/themes/powerlevel10k || {
git submodule update --init --recursive --remote --progress || {
echo "failed to update git submodules"
exit 1
}
Expand All @@ -53,12 +76,14 @@ echo "Setting up GPG/SSH"
gpg --list-keys >/dev/null

declare -a mk_dirs=(
~/.cargo
~/.cargo
~/.config
~/.continue
~/.local/bin
~/.local/share
~/.ssh
~/Library/KeyBindings
~/Library/LaunchAgents
)

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

# Fix for spacing breaking the space delimited tuples
mv "${git_submodule_path}"/catppuccin-bat/themes/Catppuccin\ Mocha.tmTheme "${git_submodule_path}"/catppuccin-bat/themes/Catppuccin-Mocha.tmTheme || {
echo "failed to move catppuccin-bat theme"
exit 1
}

declare -a symlink_paths_tuples=(
"${git_submodule_path}/alacritty-theme/themes ${base_path}/alacritty/.config/alacritty/themes"
"${git_submodule_path}/catppuccin-bat/themes/Catppuccin-Mocha.tmTheme ${base_path}/bat/.config/bat/themes/Catppuccin-Mocha.tmTheme"
"${git_submodule_path}/catppuccin-helix/themes/default/catppuccin_mocha.toml ${base_path}/helix/.config/helix/themes/catppuccin_mocha.toml"
)
for symlink_paths_tuple in "${symlink_paths_tuples[@]}"; do
read -ra symlink_paths <<<"$symlink_paths_tuple"
symlink "${symlink_paths[0]}" "${symlink_paths[1]}"
done

stow_config() {
stow -v "$1" || {
echo "Failed to stow ${1} config"
Expand All @@ -109,6 +150,7 @@ declare -a stow_dirs_setup=(
bash
git
gpg
macos
ssh
stow
zsh
Expand All @@ -119,11 +161,6 @@ for stow_dir in "${stow_dirs_setup[@]}"; do
stow_config "$stow_dir"
done

rsync --progress -ruacv -- macos/* "$HOME"/ || {
echo "failed to rsync macos config"
return 1
}

declare -a launch_agents=(
"$HOME"/Library/LaunchAgents/gnupg.gpg-agent.plist
"$HOME"/Library/LaunchAgents/gnupg.gpg-agent-symlink.plist
Expand Down

0 comments on commit 7006f4b

Please sign in to comment.