forked from colonelpanic/dotfiles
[Linux] Start using git-sync to auto-synchronize directories
This commit is contained in:
12
dotfiles/config/systemd/user/git-sync@.service
Normal file
12
dotfiles/config/systemd/user/git-sync@.service
Normal file
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=git-sync %f %I %i
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/env git_sync_directory.sh %f
|
||||
ExecStop=/usr/bin/env pkill git_sync_directory.sh
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=wm.target
|
@@ -1,11 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$1"
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
echo "Syncing $1"
|
||||
git-sync
|
||||
enable_git_sync.sh
|
||||
cd "$1"
|
||||
|
||||
while changedFile=$(inotifywait ./ -r -e modify,move,create,delete --format "%w%f" --exclude '\.git' 2>/dev/null); do
|
||||
git check-ignore "$changedFile" >> /dev/null || git-sync
|
||||
counter=0
|
||||
while true; do
|
||||
changedFile=$(inotifywait ./ -r -e modify,move,create,delete --format "%w%f" --exclude '\.git' -t 20 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
|
||||
else
|
||||
echo "Syncing for: $changedFile"
|
||||
{ git check-ignore "$changedFile" > /dev/null; } || git-sync
|
||||
fi
|
||||
done
|
||||
|
Reference in New Issue
Block a user