As I wrote in this answer to my question, I decided to use a shell script in order to concatenate the bunch of .tex files and compile them. However, this way, when ever I want to compile the whole glossary, I have to switch to the terminal and run the script there, from the right directory, i.e. the glossary's directory.

I'm using TeXShop on a mac OSX, and I want to know is there a way to set a short cut in TeXShop that will invoke the script?

Thanks, Dror.

2 Answers 2


Look in the TeXShop Macro Editor—you'll see it can be used for code snippets or scripts. The first item in the Macro menu is "AppleScripts," where you can see some examples, including some that just wrap around a shell script or command. So something like this should work:

-- #FILEPATH# in the text will be replaced by the path of the document

do shell script "cd #FILEPATH# && source generateGlossary.sh"

The first line tells TeXShop that this macro should be run as a script. The second line is just an AppleScript comment. The third line does the work.

Macros can be bound to command key combinations as well.

  • Thanks for the tip! However, I'm afraid, something doesn't work for me. Should I have do shell script "cd ~/path && ./generateGlossary.sh" or do shell script "cd ~/path && generateGlossary.sh" either case it doesn't seems to work. Any idea?
    – Dror
    Commented Nov 30, 2010 at 14:54
  • Try my edited version. Could be a permissions thing since TeXShop runs in a new environment. Commented Nov 30, 2010 at 15:15
  • I tried with this source option, but now, although it doesn't produce errors, nothing happens. I don't know even how to check if the script was invoked. I tried to have touch text.txt instead of the script call, and it did produced a file in the right directory.
    – Dror
    Commented Nov 30, 2010 at 15:31
  • Is the program you're trying to run an actual shell script? If so, you could replace "source" with the shell name...I think. Commented Nov 30, 2010 at 15:46
  • I tried to generate an applescript with the line from above, and run it. It runs, and calls my script. The problem is that the script returns an error. If I run the script directly from the terminal, it runs smoothly. I find it strange. Is there some other tip?
    – Dror
    Commented Nov 30, 2010 at 16:37

Running this sort of thing is probably better done using TeXShop's "engines" instead of calling an applescript from the Macro Editor.

If you look in your ~/Library/TeXShop/Engines folder (especially the Inactive folder) you can see various examples of such engines. The engine files themselves are just shell scripts (so they need to have the executable bit set) Once you've got the script working you can put it in the Engines folder and it will appear in the pulldown menu beside the Typeset button on any document window.

It's very possible that the script you want to run already exists (you mention glossaries). Have your looked at the LaTeXmk engine for TeXShop?

The LaTeXmk script (various versions are found in the Inactive folder; just drag them to the Engines folder and restart TeXShop to activate them.) runs all of the required numbers of latex/bibtex/mkindex/makeglossaries etc. so that everything in your document is complete. It knows about most of the major packages' extra .aux-type files, and is quite smart. The LaTeXmk engine is maintained by Herb Schulz and the latest version can be obtained from his web page.

One thing to watch out for when running scripts from within an application is that the path and environment variables set inside the application are not identical to the path and environment variables you may have set in you bash .profile or csh .cshrc file.

  • Does it make sense to do this even though my script is very much specialized to my task? Anyway, copying the bash script to the engines directory and adding the right cd at the beginning does work as expected. Adding % !TEX TS-program = glossary to each entry/file, where glossary.engine is the new engine, makes the process even quicker. One problem though: how can I tell the engine to open the generated pdf file after the process is over?
    – Dror
    Commented Feb 2, 2011 at 7:58
  • @Dror Whether it makes sense I guess depends on how often you will be doing it, I guess. As for opening the pdf you could try adding open -a TeXShop glossaries.tex at then end of the script, which should open both the source and pdf. (If you just want the pdf then open the .pdf version of the filename.)
    – Alan Munn
    Commented Feb 2, 2011 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .