25 lines
705 B
Bash
Executable File
25 lines
705 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# repo -> machine: copy tracked files from config/ into ~/.config
|
|
# Overwrites existing files, keeping a timestamped .bak of each.
|
|
set -euo pipefail
|
|
|
|
src="$(cd "$(dirname "${BASH_SOURCE[0]}")/config" && pwd)"
|
|
stamp="$(date +%Y%m%d-%H%M%S)"
|
|
|
|
shopt -s nullglob dotglob
|
|
count=0
|
|
while IFS= read -r -d '' f; do
|
|
rel="${f#"$src"/}"
|
|
dest="$HOME/.config/$rel"
|
|
mkdir -p "$(dirname "$dest")"
|
|
if [ -e "$dest" ] && ! cmp -s "$f" "$dest"; then
|
|
cp -a "$dest" "$dest.bak-$stamp"
|
|
echo "backed up: $dest -> $dest.bak-$stamp"
|
|
fi
|
|
cp -a "$f" "$dest"
|
|
echo "applied: $rel"
|
|
count=$((count + 1))
|
|
done < <(find "$src" -type f -print0)
|
|
|
|
echo "done: $count file(s) applied to ~/.config"
|