3

Lion added the ability to Quick Look a URL in an application (like Mail.app). I would like to use that functionality from a script.

Is that possible?

2 Answers 2

4

There is also an Automator action for displaying a website in a Quick Look like window:

automator -i http://apple.com Desktop/Website\ Popup.workflow

3

Yes, it is possible, but not directly from the internet. The file needs to be downloaded first.

qlmanage -p '/path/to/file'

will show the quick look preview for that file. It will also write some debug information to stderr, so I usually append >/dev/null 2>&1 to the end of the command.

In your case, you will need to download the file first in order to get to the Quick Look preview. You also need the proper extension for qlmanage to recognize the file. cd ~/tmp; curl "$url" --O "quicklook.$extension" will download it into ~/tmp (this directory needs to exist) and you will need to set the extension beforehand with extension=${url##*.}.


The final shell script:

cd ~/tmp
url='http://images.apple.com/mac/home/images/hero_30years_then.jpg'
extension=${url##*.}
curl "$url" --O "quicklook.$extension"
qlmanage -p "quicklook.$extension"

And in an applescript:

set quicklookurl to "http://images.apple.com/mac/home/images/hero_30years_then.jpg"
do shell script "cd ~/tmp; url=" & quoted form of quicklookurl & "; extension=${url##*.}; curl \"$url\" --O \"quicklook.$extension\"; qlmanage -p \"quicklook.$extension\""
1
  • But this will probably break on most complex web pages.
    – Fuzzy76
    Commented Jul 25, 2018 at 13:29

You must log in to answer this question.

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