[Tex/LaTex] External scripts when using TeXShop

editorsscriptstexshop

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.

Best Answer

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:

--AppleScript
-- #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.