-
Notifications
You must be signed in to change notification settings - Fork 2
/
sync-home.sh
executable file
·33 lines (26 loc) · 965 Bytes
/
sync-home.sh
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
#!/usr/bin/env bash
# So if you've noticed, the directory structure of my repo and home folder is exactly the same.
# I got sick of manually copying files to my repo and this stupid script is came to live.
# It's just syncs exactly to the files in this repo from my home folder, if it's exist.
# Feel free to steal it :D
TEMP=/tmp/included
if [[ -e $TEMP ]]; then
rm "$TEMP"
fi
git ls-tree -r main --name-only > "$TEMP"
while read -r DEST; do
TARGET="$HOME/$DEST"
# Exclude big folders to speed up.
if [[ -e $TARGET && $TARGET != *".icons"* && $TARGET != *".themes"* ]]; then
DIFF=$(diff "$TARGET" "$DEST")
if [[ -z "$DIFF" ]]; then
continue;
else
echo "=> Copying $DEST"
rsync -aqzrEP --no-perms --no-owner --no-group "$TARGET" "$DEST"
#cp -r --parents --no-preserve=mode,ownership "$TARGET" .
fi
fi
done < "$TEMP"
#cp -R home/alcadramin/* .
#rm -r home/