summaryrefslogtreecommitdiff
path: root/watch-calendars
blob: cbae9be22ea053e96dbefa7216c8aed3e5f14672 (plain)
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
#!/bin/bash

if [ $# -eq 0 ]; then
  find ~/.local/share/khal/calendars \
    -type d \
    -mindepth 1 \
    -maxdepth 1 \
  | parallel -j0 "$0"
  exit $?
fi

dir=$(
  readlink -e "$1"
)

cd "${dir}" || exit $?

while [ -d "${dir}" ]; do
  inotifywait -r . -e CREATE,MOVED_TO -t 30
  if [ $? -eq 0 ]; then
    git commit -am'update by '"$(whoami)"'@'"$(hostname)"' on '"$(date)"
  fi
  git pull --rebase
  git push
done