-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff
More file actions
executable file
·34 lines (29 loc) · 831 Bytes
/
Copy pathdiff
File metadata and controls
executable file
·34 lines (29 loc) · 831 Bytes
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
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
set -uo pipefail
# Diff between local ($HOME) and repository
#
# Maintainer: asccigcc
#
# Usage:
# ./diff
# Run from the repo root so `source config.txt` works from any CWD.
cd "$(dirname "$0")" || exit 1
# Load config variables (files, directories)
source config.txt
# `diff` exits non-zero when inputs differ; `|| true` keeps set -o pipefail happy.
for file in "${files[@]}"; do
diff_output=$(diff -u "${HOME}/${file}" "$file" || true)
if [[ -n $diff_output ]]; then
echo -e "\033[32mDiff ${file}\033[0m"
echo "$diff_output"
echo
fi
done
for dir in "${directories[@]}"; do
diff_output=$(diff -ru "${HOME}/${dir}" "$dir" || true)
if [[ -n $diff_output ]]; then
echo -e "\033[32mDiff ${dir}\033[0m"
echo "$diff_output"
echo
fi
done