summaryrefslogtreecommitdiff
path: root/link.sh
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
committerIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
commit13cc065ec014b86369dfe4ad60d1a43fa06fd251 (patch)
tree684690c61b7b59758c2aac132c65b81c86de0608 /link.sh
dotfiles
Shell, editor and terminal configuration, the tools that go with them, and szecret, an age-based secret manager whose store lives elsewhere. History restarts here. What came before was not written to be read by anyone else, and carried machine names, addresses and an encrypted secret store; it is kept privately instead. What is left is meant to be safe on any machine, including one whose owner is not me: see CLAUDE.md for the rule it is written to.
Diffstat (limited to 'link.sh')
-rwxr-xr-xlink.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/link.sh b/link.sh
new file mode 100755
index 0000000..f5e08d5
--- /dev/null
+++ b/link.sh
@@ -0,0 +1,80 @@
+#!/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/extensions" "$HOME/.pi/agent/extensions"
+link "$config_dir/pi/models.json" "$HOME/.pi/agent/models.json"
+# settings.json is generated by link/pi.sh; 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
+
+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