I'm using Mac OS X and TeXShop. I wrote a linux script which does some text substitutions and then calls the following main commands:

latex MyFile
biber MyFile
latex MyFile
latex MyFile

After the execution of the script, how can I call the TeXShop-pdf-Viewer?

Right now, I'm obliged to get back to TeXShop and to compile once again to visualize the pdf file and I'd like to automate this step.

  • 1
    You can use open -a TeXShop <file.pdf>
    – Alan Munn
    Commented Jan 29, 2018 at 15:31

1 Answer 1


The MacOS has an open command which allows you to open any application or document from the command line. So you can use

open -a TeXShop <file.pdf>

to open the PDF from your script.

Since I assume you're using an external editor to edit the source, you should set the TeXShop preferences to Configure for External Editor, and in the Preview panel of the preferences, choose Automatic Preview Update.

  • Thanks @Alan Munn. It works fine. However, if the pdf file is already opened in the viewer, is there a way to update the display instead of opening a new viewer.
    – rasha
    Commented Jan 29, 2018 at 21:44
  • The displayed file does not correspond to the latest compilation! It opens an older compilation (as said before in a new window file).
    – rasha
    Commented Jan 29, 2018 at 22:15
  • @rasha Did you change the preferences as I suggested? (Automatic Preview Update)?
    – Alan Munn
    Commented Jan 29, 2018 at 22:22
  • Yes I did and both issues persist: (i) the first time I execute the suggested command, a new viewer is launched instead of updating the text in the one which is already opened. (ii) The displayed text does not correspond to the latest compilation. Even after executing my script many times (with multiple compilations), an old file is displayed. The former issue is less problematic than the latter, because the new viewer is launched only once.
    – rasha
    Commented Jan 30, 2018 at 14:43
  • @rasha The solution works for me. When you changed the preferences, did you restart TeXShop?
    – Alan Munn
    Commented Jan 30, 2018 at 16:13

You must log in to answer this question.

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