TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make use of the minted package for source code highlighting, and am running into an error telling me I need to install pygmentize combined with an message regarding the --shell-escape flag.

I confirmed that running

$ xelatex --shell-escape my.tex

will compile correctly, but compilation via TexShop doesn't seem to be calling this flag and I cannot find a way to set it correctly. In the TexShop preferences, I did check that the pdfTeX commands have the --shell-escape flag set, but this does not seem to help or matter.

If someone could point out to me the way to inform TexShop about this flag for xelatex I'd be grateful.

share|improve this question
up vote 13 down vote accepted

You should have a file called XeTeX.engine


You can open it with TextEdit and change the last line from

xelatex "$1"


xelatex  --shell-escape "$1"

However this will always call XeLaTeX with the option. You can duplicate the file, giving the copy a name such as XeLaTeX-shellescape.engine and modify this one. You'll have both engines in the menu and you'll be able to set the "magic line" to use this new engine

% !TEX TS-program = XeLaTeX-shellescape
share|improve this answer
awesome, that worked like a charm. as a follow-up, is there any downside to running it by default with the --shell-escape flag? – d7slaks87 Feb 24 '12 at 17:17
In case you receive a file from a non trusted source there are security risks. – egreg Feb 24 '12 at 17:21
Do you know if there's any way to tell TeX that the pygmentize command is safe to run, but not any of the others? Even that has security risks if somebody finds an arbitrary-code bug in pygmentize, but is still safer than "any command you want, including :(){ :|: & };: or rm -rf /*". – Daniel H Feb 13 '13 at 15:01
@DanielH minted checks for -shell-escape and refuses to work if it's not used. – egreg Feb 13 '13 at 15:47
I understand that; I was wondering if I could tell XeLaTeX to only allow a partial shell escape (and perhaps I'd have to modify minted if its check would be incompatible). Something like -shell-escape=pygmentize. I can't find anything about -shell-escape in the documentation of MikTex. Actually, I'm promoting this to a full question, as it's not particularly relevant here.. – Daniel H Feb 13 '13 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.