How to update Preview.app from the command line without losing focus on Mac OS X?

I want to update Preview.app in the background from the command line without losing focus of my current window. I know that I can use the following to open/update the view of a file, but then I lose focus to the Preview.app.

open -a Preview foo.pdf

I guess there might be some clever AppleScript commands to do so but so far I didn't find the right one.

Alternatively I would be interested into transfering the focus back to my current application directly after the update. I need this in order to update Preview.app's view of a PDF file through a vi autocmd after I update the PDF file according to changes in a TeX file I am editing. Here is an example of what I want to achieve but using Ubuntu and evince.

2 Answers

Meanwhile i was told the solution by a nice person called Guillermo commenting on my blog. The solution is to use:

open -g -a Preview foo.pdf

to update the pdf in the background.

4

The is a rather old thread. I don't know whether you can do this 10 years ago. But currently you only have to open -g xxx.pdf

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like