#!/usr/bin/env bash set -euo pipefail DOTFILES_DIR="$HOME/dotfiles" function link_configs { echo "Linking configuration files..." declare -A mappings # TODO: Make this linux compatible mappings["ghostty"]="$HOME/Library/Application Support/com.mitchellh.ghostty" mappings["zsh/zshenv"]="$HOME/.zshenv" mappings["zsh/zshrc"]="$HOME/.zshrc" mappings["misc/tmux.conf"]="$HOME/.tmux.conf" mappings["git/gitconfig"]="$HOME/.gitconfig" mappings["git/gitignore"]="$HOME/.gitignore" mappings["misc/vimrc"]="$HOME/.vimrc" mappings["nvim"]="$HOME/.config/nvim" mappings["glide"]="$HOME/.config/glide" mappings["misc/global-tool-versions"]="$HOME/.tool-versions" mappings["ai/skills"]="$HOME/.claude/skills" mappings["hammerspoon"]="$HOME/.hammerspoon" mappings["zsh/starship.toml"]="$HOME/.config/starship.toml" for key in "${!mappings[@]}"; do source="${key}" destination="${mappings[$key]}" if [ -d "$source" ]; then mkdir -p "$(dirname "$destination")" create_symlink "$source" "$destination" elif [ -f "$source" ]; then create_symlink "$source" "$destination" else echo "Warning: Source $source does not exist, skipping." fi done } function create_symlink { local source="$1" local destination="$2" echo "$source -> $destination" if [ -L "$destination" ]; then if [ "$(readlink "$destination")" = "$DOTFILES_DIR/$source" ]; then echo " Already established" return else echo " Removing existing symlink ($(readlink "$destination"))" rm "$destination" fi fi if [ -e "$destination" ]; then echo " Destination exists, backing it up" mv "$destination" "${destination}.bak" fi echo " Creating symlink" ln -s "$DOTFILES_DIR/$source" "$destination" } function install_oh_my_zsh { if [ -d "$HOME/.oh-my-zsh" ]; then echo "Oh My Zsh is already installed." return fi sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended } function install_tpm { if [ -d "$HOME/.tmux/plugins/tpm" ]; then echo "TPM is already installed." return fi git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm } link_configs install_oh_my_zsh install_tpm