forked from DarkStarSword/junk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inotify_sync.sh
executable file
·46 lines (35 loc) · 1.01 KB
/
inotify_sync.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
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
cd $(git rev-parse --show-toplevel)
if [ ! -d .git ]; then
echo Run me in a git tree!
exit 1
fi
echo "Monitoring $(pwd)"
while true; do
# [0-9]+ here is to ignore some weird files that vim seems to create
# and delete before doing it's actual save/backup dance. Now that I
# explicitly wait for the filesystem to settle I could probably remove
# it pretty safely.
inotifywait -e close_write -q -r --exclude '.*\.swp?x?$|/[0-9]+$|/\.git/' .
while true; do
echo -n Waiting for filesystem to settle...
while inotifywait -t 1 -q -q -r .; [ $? -ne 2 ]; do
echo -n .
sleep 0.1
done
echo
if ls .git/rebase-* 2>/dev/null; then
echo Waiting for in progress git rebase to finish...
inotifywait -e delete -q -r .git/rebase-*
continue
fi
if ls .git/*.lock 2>/dev/null; then
echo Waiting for lock to clear...
inotifywait -e delete -q -r .git/*.lock
continue
fi
# TODO: Look for other signs that git is in the middle of something...
break; done
git-push-wd.sh "$@"
echo
done