There are several tools which can can help you.
arara
The cool tool arara
provides several rules to specify all compilation steps from inside the document.
For example you want to compile with pdflatex
+bibtex
+pdflatex
you need the following lines in the preamble of the main document:
% arara: pdflatex
% arara: bibtex
% arara: pdflatex
After this specifications you can compile your document with
arara myfile.tex
Options to the rules can be given too.
% arara: pdflatex: { options: { -aux-directory=auxdir } }
% arara: bibtex: { files: [auxdir/filename1, auxdir/filename2] }
TrY
Another but equal method is the tool TrY. It works only for Unix systems and instead of rules you can type complete small scripts.
The adapted example from above with TrY is:
%$ pdflatex myfile.tex
%$ bibtex myfile.aux
%$ pdflatex myfile.tex
and the compilation step is:
try myfile.tex
In addition to Кигава Енсеи's answer for typesetting with the xelatex engine, below minor alteration works perfectly in TeXShop using pdflatex for typesetting
Just change xelatex' to
pdflatex' and it will work
Best Answer
hmmmm. Are you sure you want to do this? You need .aux files for subsequent compiles and sometime you need to compile three times until everything is worked out properly (like with note connections, I think). It might be better to set up your editor so that it cleans up when you close the file, or close the editor, or something like that.....cleaning up after every compile smells like trouble to me. Not that I know how to do that...but I'm just sayin'.