link.sh (1683B)
1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 5 PROGRAMS_DIR="$(dirname "$SCRIPT_DIR")/programs" 6 CONFIG_DIR="$HOME/.config" 7 8 echo "🔗 Symlinking config files..." 9 10 link_config() { 11 local src="$1" 12 local dest="$2" 13 14 echo "→ Linking $src → $dest" 15 16 if [ -L "$dest" ] || [ -d "$dest" ]; then 17 echo "→ Removing existing $dest" 18 rm -rf "$dest" 19 elif [ -e "$dest" ]; then 20 echo "→ Backing up existing $dest to $dest.bak" 21 mv "$dest" "$dest.bak" 22 fi 23 24 mkdir -p "$(dirname "$dest")" 25 ln -s "$src" "$dest" 26 echo "✅ Linked $dest" 27 } 28 29 # Fish 30 link_config "$PROGRAMS_DIR/fish/config.fish" "$CONFIG_DIR/fish/config.fish" 31 link_config "$PROGRAMS_DIR/fish/fish_plugins" "$CONFIG_DIR/fish/fish_plugins" 32 link_config "$PROGRAMS_DIR/fish/secrets.fish" "$CONFIG_DIR/fish/secrets.fish" 33 34 # Neovim 35 link_config "$PROGRAMS_DIR/nvim" "$CONFIG_DIR/nvim" 36 37 # Btop 38 link_config "$PROGRAMS_DIR/btop/btop.conf" "$CONFIG_DIR/btop/btop.conf" 39 40 # GitHub CLI 41 link_config "$PROGRAMS_DIR/gh/config.yml" "$CONFIG_DIR/gh/config.yml" 42 43 # OpenCode 44 link_config "$PROGRAMS_DIR/opencode/opencode.json" "$CONFIG_DIR/opencode/opencode.json" 45 link_config "$PROGRAMS_DIR/opencode/command" "$CONFIG_DIR/opencode/command" 46 link_config "$PROGRAMS_DIR/opencode/plugin" "$CONFIG_DIR/opencode/plugin" 47 48 # Karabiner 49 link_config "$PROGRAMS_DIR/karabiner/karabiner.json" "$CONFIG_DIR/karabiner/karabiner.json" 50 link_config "$PROGRAMS_DIR/karabiner/assets" "$CONFIG_DIR/karabiner/assets" 51 52 # Zed 53 link_config "$PROGRAMS_DIR/zed/settings.jsonc" "$CONFIG_DIR/zed/settings.json" 54 link_config "$PROGRAMS_DIR/zed/keymap.jsonc" "$CONFIG_DIR/zed/keymap.json" 55 56 echo "✅ Config symlinks complete!"