Files
2026-11-01 13:49:47 +01:00

32 lines
803 B
Bash
Executable File

#!/usr/bin/env bash
# machine -> repo: copy current ~/.config files into config/
# Only files that already exist under config/ are collected,
# so nothing gets tracked by accident.
set -euo pipefail
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
dst="$repo/config"
shopt -s nullglob dotglob
count=0
missing=0
while IFS= read -r -d '' f; do
rel="${f#"$dst"/}"
src="$HOME/.config/$rel"
if [ ! -f "$src" ]; then
echo "missing on this machine: $rel (skipped)"
missing=$((missing + 1))
continue
fi
if cmp -s "$src" "$f"; then
echo "unchanged: $rel"
else
cp -a "$src" "$f"
echo "collected: $rel"
fi
count=$((count + 1))
done < <(find "$dst" -type f -print0)
echo "done: $count tracked file(s) checked, $missing missing"
echo "review with: git -C '$repo' diff"