changes from ryzen-shine on Wed Jul 14 08:42:35 PM MDT 2021

This commit is contained in:
2021-07-14 20:42:35 -06:00
parent b8e66b25bf
commit e4120258c1
7 changed files with 69 additions and 29 deletions

View File

@@ -1,22 +1,30 @@
#!/usr/bin/env zsh
echo "Syncing $1"
#!/usr/bin/env bash
echo "Syncing $2 at $1 with a default sync interval of $3"
# Initialize the directory
if [ ! -d "$1" ]; then
base="$(dirname $1)"
mkdir -p "$base"
cd "$base"
git clone "$2" "$(basename $1)"
fi
cd "$1"
counter=0
while true; do
changedFile=$(inotifywait ./ -r -e modify,move,create,delete --format "%w%f" --exclude '\.git' -t 60 2>/dev/null)
changedFile=$(
inotifywait ./ -r -e modify,move,create,delete \
--format "%w%f" --exclude '\.git' -t $3 2>/dev/null
)
if [ -z "$changedFile" ]
then
counter=$((counter+1))
if [ $counter -gt 4 ]; then
git-sync
counter=0
else
git-sync > /dev/null
fi
echo "Syncing due to timeout"
git-sync -n -s
else
echo "Syncing for: $changedFile"
{ git check-ignore "$changedFile" > /dev/null; } || git-sync
{ git check-ignore "$changedFile" > /dev/null; } || git-sync -n -s
fi
done