link.sh (view raw)
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 |
#!/bin/bash
# Link this repo into $HOME. Dry run by default; pass `yes` to apply.
#
# The plain one-line links live here. Anything with logic of its own is a part
# in link/: a script with this same interface that decides for itself whether
# it applies, and can be run on its own (`link/ssh.sh yes`). Their shared
# helpers are in link/lib.sh.
set -euo pipefail
# shellcheck source-path=SCRIPTDIR
# shellcheck source=link/lib.sh
source "$(dirname "$0")/link/lib.sh" "$@"
# config/env is the environment layer, loaded by every shell in every mode:
# via ~/.zshenv for zsh, and via ~/.profile (login) + $BASH_ENV for bash.
# config/profile is the interactive layer and sources ~/.env itself.
link "$config_dir/env" "$HOME/.env"
link "$config_dir/profile" "$HOME/.profile"
link "$config_dir/tmux.conf" "$HOME/.tmux.conf"
link "$config_dir/zshenv" "$HOME/.zshenv"
link "$config_dir/zprofile" "$HOME/.zprofile"
link "$config_dir/zshrc" "$HOME/.zshrc"
link "$config_dir/bashrc" "$HOME/.bashrc"
link "$config_dir/ideavimrc" "$HOME/.ideavimrc"
link "$config_dir/alacritty" "$xdg_config_dir/alacritty"
link "$config_dir/ghostty" "$xdg_config_dir/ghostty"
link "$config_dir/tmux" "$xdg_config_dir/tmux"
link "$config_dir/git/config" "$xdg_config_dir/git/config"
link "$config_dir/lsd/config.yaml" "$xdg_config_dir/lsd/config.yaml"
link "$config_dir/lsd/icons.yaml" "$xdg_config_dir/lsd/icons.yaml"
link_all "$config_dir/nvim" "$xdg_config_dir/nvim"
link_all "$config_dir/bat" "$xdg_config_dir/bat"
link "$config_dir/aider.conf.yml" "$HOME/.aider.conf.yml"
link "$config_dir/pi/compact-tools.json" "$HOME/.pi/agent/compact-tools.json"
# extensions/, settings.json and models.json are all link/pi.sh's; AGENTS.md and
# mcp.json, if any, come from another layer.
# Utils
bin="$HOME/.bin"
link_all "$dotfiles_dir/bin" "$bin"
link "$dotfiles_dir/bin/vi" "${bin}/vim"
link "$dotfiles_dir/secrets/main.sh" "${bin}/szecret"
# Other repos' link.sh, after bin/ above -- cloud-setup links into ~/.bin too --
# and before the parts below, which read what it links in: link/claude.sh
# registers the MCP servers in ~/.config/claude/mcp-servers.d/.
# DOT_LINK_LIB: other repos' link.sh source this repo's link/lib.sh rather than
# keeping copies, and this tells them where it is, so neither repo has to know
# where the other is checked out.
cloud_setup="$HOME/src/soarez/cloud-setup"
if [[ -d "$cloud_setup" ]]
then
DOT_LINK_LIB="$dotfiles_dir/link/lib.sh" run_link "$cloud_setup/link.sh"
fi
# A part named in ~/.config/dot/skip leaves this machine alone: link/lib.sh
# checks that as each part starts, so a part run on its own obeys it as well.
for part in ssh claude pi skills icloud hammerspoon kwin
do
run_link "$dotfiles_dir/link/$part.sh"
done
# Short-link CLI (sz-link), only where link.soarez.org is already checked out.
# Never cloned from here: this runs unattended on the auto-link hosts, and every
# extra checkout is one more that can go stale and deploy old links. Checks the
# script rather than the directory, so a checkout from before sh/link.sh existed
# is skipped instead of aborting this run.
sz_link_sh="$HOME/src/soarez/link.soarez.org/sh/link.sh"
if [[ -x "$sz_link_sh" ]]
then
run_link "$sz_link_sh"
fi
if [[ -n "${is_dry_run}" ]]
then
echo "Execute with: $0 yes"
fi
|