xonecas.io
56101
Df

dotfiles / commit ca2675f

feat: add config install scripts

Sean2026-01-29 ca2675f5203fc0fb36d2791bf242fa95f6fda06d parent a682b4f

2 files changed

install.sh+43−0
@@ -0,0 +1,43 @@
1+#!/usr/bin/env bash
2+# Install configs from this repo to XDG config dir.
3+# Usage: ./install.sh [config ...]; no args installs all configs.
4+# If a config has its own install.sh, it is executed instead of linking.
5+set -euo pipefail
6+
7+repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+config_root="${XDG_CONFIG_HOME:-$HOME/.config}"
9+
10+configs=()
11+if [ "$#" -gt 0 ]; then
12+ configs=("$@")
13+else
14+ shopt -s nullglob
15+ for dir in "$repo_dir"/*; do
16+ if [ -d "$dir" ]; then
17+ configs+=("$(basename "$dir")")
18+ fi
19+ done
20+fi
21+
22+for config in "${configs[@]}"; do
23+ config_dir="$repo_dir/$config"
24+ if [ ! -d "$config_dir" ]; then
25+ echo "Unknown config: $config" >&2
26+ exit 1
27+ fi
28+
29+ if [ -f "$config_dir/install.sh" ]; then
30+ bash "$config_dir/install.sh"
31+ continue
32+ fi
33+
34+ mkdir -p "$config_root"
35+ target="$config_root/$config"
36+ if [ -e "$target" ] || [ -L "$target" ]; then
37+ echo "Skipping $config (target exists): $target"
38+ continue
39+ fi
40+
41+ ln -s "$config_dir" "$target"
42+ echo "Linked $config -> $target"
43+done
opencode/install.sh+35−0
@@ -0,0 +1,35 @@
1+#!/usr/bin/env bash
2+# Link opencode config files and directories into ~/.config/opencode, skipping existing targets.
3+set -e
4+
5+config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/opencode"
6+commands_dir="$config_dir/commands"
7+skills_dir="$config_dir/skills"
8+repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
10+mkdir -p "$config_dir" "$commands_dir" "$skills_dir"
11+
12+if [ ! -e "$config_dir/AGENTS.md" ] && [ ! -L "$config_dir/AGENTS.md" ]; then
13+ ln -s "$repo_dir/AGENTS.md" "$config_dir/AGENTS.md"
14+fi
15+
16+shopt -s nullglob # Avoid literal glob patterns when directories are empty.
17+for item in "$repo_dir/commands"/*; do
18+ if [ -f "$item" ]; then
19+ target="$commands_dir/$(basename "$item")"
20+ if [ ! -e "$target" ] && [ ! -L "$target" ]; then
21+ ln -s "$item" "$target"
22+ fi
23+ fi
24+done
25+
26+for item in "$repo_dir/skills"/*; do
27+ if [ -d "$item" ]; then
28+ target="$skills_dir/$(basename "$item")"
29+ if [ ! -e "$target" ] && [ ! -L "$target" ]; then
30+ ln -s "$item" "$target"
31+ fi
32+ fi
33+done
34+
35+echo "Linked opencode config to $config_dir"