26 lines
444 B
Bash
Executable file
26 lines
444 B
Bash
Executable file
#!/bin/sh -e
|
|
|
|
test -d files/ || {
|
|
>&2 echo "Not in dotfiles root"
|
|
exit 1
|
|
}
|
|
|
|
for arg in $@; do
|
|
arg="$(realpath -s "$arg")"
|
|
file="${arg#"$HOME"/}"
|
|
|
|
test "$arg" != "$file" || {
|
|
>&2 echo "$file is not in $HOME"
|
|
continue
|
|
}
|
|
|
|
test ! -e "files/$file" || {
|
|
>&2 echo "$file is already added"
|
|
continue
|
|
}
|
|
|
|
mkdir -vp "files/$(dirname "$file")"
|
|
mv -iv "$arg" "files/$file"
|
|
ln -vfs "$(realpath "files/$file")" "$arg"
|
|
echo "added"
|
|
done
|