dots/add.sh
2026-01-31 12:19:05 +01:00

21 lines
366 B
Bash
Executable file

#!/bin/sh -e
test -d files/ || {
>&2 echo "Not in dotfiles root"
exit 1
}
for arg in $@; do
arg="$(realpath "$arg")"
file="${arg#"$HOME"}"
test "$arg" != "$file" || {
>&2 echo "$f is not in $HOME"
continue
}
cp -rv "$arg" "${arg}.bak"
mkdir -vp "files/$(dirname "$file")"
mv -iv "$arg" "files/$file"
ln -vfs "$(realpath "files/$file")" "$arg"
done