3 # Print diffs for each _FILE, ~/.FILE pair
5 # There are two modes: removed and standard. In standard mode, we show
6 # the transition .file -> ~/.file, which shows the changes changes we
7 # need to apply to dotfiles to create your current local installation.
8 # In remove mode, we list the .files that do not have local ~/.file
9 # analogs (i.e. dotfiles that need to be removed to create your
10 # current local installation). The --removed option selects removed
13 if [ -z "${DOTFILES_DIR}" ]; then
14 echo "DOTFILES_DIR is not set. Bailing out."
21 while [ -n "${1}" ]; do
33 if [ "${MODE}" = 'local-patch' ]; then
35 mkdir -p local-patch || exit 1
36 echo 'save local patches to local-patch/000-local.patch'
37 ./bin/diff.sh > local-patch/000-local.patch || exit 1
38 echo 'save local removes to local-patch/000-local.remove'
39 ./bin/diff.sh --removed > local-patch/000-local.remove || exit 1
43 cd "${DOTFILES_DIR}/src" || exit 1
45 # Show the changes we'd apply on installation
48 # file - The file we're processing '.foo'
49 function handle_file()
52 if [ "${MODE}" = 'removed' ]; then
53 if [ ! -e ~/"${FILE}" ]; then
57 if [ -f ~/"${FILE}" ]; then
58 diff -u "${FILE}" ~/"${FILE}"
63 # For each file in this directory.
66 if [ "${FILE}" = '.' ]; then
69 FILE="${FILE:2}" # strip the leading './'
71 let "FOUND = FOUND + 1"
74 # If we found no .XXX files, print a warning
75 if [ "${FOUND}" -lt 1 ]; then
76 echo 'WARNING: no source dotfiles were found' >&2