diff --git a/autocompile.sh b/autocompile.sh
new file mode 100755
index 0000000000000000000000000000000000000000..bb968707ba0e805404cd21f6a8e62ffa31f1a8d3
--- /dev/null
+++ b/autocompile.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# if you're in the subtree, back up
+[ ! -d .git ] && [ -e ../.git ] && \
+	cd ..
+
+# If you're setting up:
+[ ! -e main.tex ] && [ -e config/main.tex ] && \
+	cp config/main.tex . && \
+	ln -s config/autocompile.sh .
+
+
+if [ $1 = clean ]; then
+	rm -r *aux *log main.{i,g}* *toc *.ptc *.out svg-inkscape 2>/dev/null
+	exit 0
+fi
+
+if [ $1 = tree ]; then
+	[ -e ../config ] || ( echo "You don't have a local config repo" && exit 1 )
+	git status
+	git subtree -P config pull ../config master
+	git subtree -P config push ../config master
+fi
+pdflatex -shell-escape main.tex
+makeglossaries main
+makeindex main.idx
+pdflatex main.tex