add apply.sh
This commit is contained in:
1 parent
0ecb52b6e7
commit
c547a19ac7
1 file changed
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/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"
|
||||||
Reference in new issue
Block a user