#!/bin/bash
-cd ~;
+ORG_GREP='-e .org$ -e .org_archive$ -e .org_done$'
-for a in $(mr list |grep 'list:'|grep -v 'finished'|awk -F'list: ' '{print $2}' 2>/dev/null); do
- (cd "$a";
- if git status --porcelain|grep '^ M'|grep -q '.org$'; then
- git commit -m'update org files' $(mr --no-recurse status |grep '^ M'|grep '.org$'|sed 's/^ M//g');
- git push;
- fi;
- );
-done;
+COMMIT_MESSAGE="${1:-update org files}"
+
+if [ "x$UPDATE_ORG_REALLY_DO_IT" == "xyesdoit" ]; then
+ if git status --porcelain -z | grep -z '^ M' | grep -zq $ORG_GREP; then
+ git status --porcelain -z | grep -z '^ M' | grep -z $ORG_GREP | \
+ sed -z 's/^ M[[:space:]]*//g' | \
+ xargs -0 git commit -m"$COMMIT_MESSAGE"
+ git pull --rebase;
+ git push;
+ else
+ git pull --rebase;
+ fi;
+else
+ if [ "x$NO_SAVE_ORG_BUFFERS" == "x" ]; then
+ emacsclient -n -e '(org-save-all-org-buffers)' >/dev/null 2>&1
+ fi;
+ UPDATE_ORG_REALLY_DO_IT="yesdoit" mr -d ~/projects/org-notes -j5 run \
+ update_org_files "$COMMIT_MESSAGE"
+ UPDATE_ORG_REALLY_DO_IT="yesdoit" mr -d ~/org-mode -j5 run \
+ update_org_files "$COMMIT_MESSAGE";
+fi;