-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync
executable file
·31 lines (25 loc) · 1.1 KB
/
sync
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
#!/usr/bin/env bash
echo Starting uncommitted-changes-sync
# trap to kill processes that we start in this script when this script finishes
trap "kill 0" EXIT
SCRIPT_DIR=${0%/*}
echo Assuming the directory with the sync scripts is ${SCRIPT_DIR}
# by default, we expect the config file to be in ~/.config/uncommited_changes_sync
CONFIG_PATH=${1:-"${HOME}/.config/uncommitted_changes_sync"}
# loop over lines in config file
# use sed to remove lines starting with "#" or empty lines
echo Reading config at "${CONFIG_PATH}"
sed -e "/^#\\|^\$/d" < "${CONFIG_PATH}" | while read localpath_unexpanded git_branch host remotepath; do
# in case there's something like $HOME in the localpath, evaluate it to expand path
eval localpath=$localpath_unexpanded
echo
echo Adding new sync repository:
echo " local path: $localpath"
echo " git branch: $git_branch"
echo " host: $host"
echo " remote path: $remotepath"
${SCRIPT_DIR}/inotifydo ${SCRIPT_DIR}/git_upd $localpath $git_branch $host $remotepath &
done;
echo "Done setting up syncers."
# This is elegant, I know!
sleep infinity