~kaction/config

ref: milestone/1 config/maint/what-changed -rwxr-xr-x 591 bytes
8f4e28c9 — Dmitry Bogatov vim: drop custom implementation of snippets 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh -eu
export LC_ALL=C
tempdir=$(mktemp -p "${TEMPDIR:=/tmp}" -d "config.XXXXXX")
cleanup () { rm -fr "${tempdir}" ; }
trap cleanup 0

if [ ! -f ~/config.tar.gz ] ; then
    printf >&2 'fatal: no config.tar.gz in home directory\n'
    exit 1
fi

mkdir -p "${tempdir}/old"
ln -sf ~ "${tempdir}/new"

tar -xzf ~/config.tar.gz -C "${tempdir}/old/"
(
    cd "${tempdir}"
    diff -drU5 "old/" "new/" 2>&1 \
    | sed -r '/(Only in|No such file or directory)/ d' \
    | tee "${tempdir}/patch"
)

if [ "${1:-none}" = '--apply' ] ; then
    cd src/copy && patch -p1 < "${tempdir}/patch"
fi