Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Nice. After you posted your question I experimented a bit with AppleScript, as "all" it takes for Preview to update an open document is just give it focus. (Like: open a PDF, change it using some other program, and then go back to Preview: it will update it right away.) Hence, no need to manually reload the document by calling open, if one could just, somehow, fool Preview into thinking it has focus. But I did NOT find any solution. (Even more, I discovered that Preview is not that easily scripted, if at all...) –  Arjan Mar 29 '10 at 9:24
    
If I try this on Lion the PDF still isn't updated until it gets focus. Any idea how to fix it? (BTW: Your blog gives an error) –  Alessandro Vermeulen Dec 13 '11 at 12:24
    
doesn't work for me either (Lion) –  romeovs Dec 19 '11 at 11:38
    
I just tested on Lion and you are correct preview does not show the new content until focused. So this solution does not work in Lion. –  snies Jan 16 '12 at 23:28

Your Answer

 
discard

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.