Use Quick Look from the Command line with qlmanage
Quick Look is a nice feature in Mac OS X for quickly previewing documents, images, and other file data before opening it into a designated application. I use Quick Look often for glancing at the content of various documents and it certainly beats launching an application when you just need to take a quick peak at something, whether it’s to confirm contents or verify you’re working with the proper file. If you’re an avid command line user though, you may be browsing through a directories contents and wondering just what is that JPG or DOC file.
Wonder no more, because you can easily use Quick Look from the command line of Mac OS to open Quick Look previews right from the Terminal application.
From the command line Terminal app, use the following syntax to open a file with Quick Look:
qlmanage -p filename.jpg
That command and -p flag will launch a Quick Look window with whatever file is specified as ‘filename.jpg’, the file type can be anything that Quick Look is compatible with (which seems to be just about everything). And yes, Quick Look will open the file preview in a new window.
The qlmanage command has other abilities, including various advanced features that offer performance related information, diagnostics, and customizations to how Quick Look functions. You can also reset Quick Look cache and restart the quicklookd daemon server using the command line tool. A complete flag list of qlmanage is available at the command line, repeated below, courtesy of qlmanage -h:
Usage: qlmanage [OPTIONS] path...
-h Display this help
-r Force reloading Generators list
-r cache Reset thumbnail disk cache
-m [name ...] Display statistics about quicklookd. Stats names:
* plugins Show the generators list
* server Show quicklookd life information
* memory Show quicklookd memory consumption
* burst Show statistics about the last burst
* threads Show concurrent accesses stats
* other Show other information about quicklookd
-d debugLevel Integer between 1-4
-p Compute previews of the documents
-t Compute thumbnails of the documents
-x Use quicklookd (remote computation)
-i Compute thumbnail in icon mode
-s size Size for the thumbnail
-f factor Scale factor for the thumbnail
-F factor Scale factor for the thumbnail, draw downscaled and compare to 1x
-z Display generation performance info (don't display thumbnails)
-o dir Output result in dir (don't display thumbnails or previews)
-c contentType Force the content type used for the documents
-g generator Force the generator to use
Note that you can have Quick Look launch in the background by using the following command, allowing you to continue using the Terminal as usual:
qlmanage -p filename.jpg &
You can point qlmanage at many more file types than a simple image or jpg, so have fun.
For troubleshooting Quick Look, often refreshing the cache and reloading thumbnails is sufficient to remedy issues, you can issue both commands simultaneously as so:
qlmanage -r cache && qlmanage -r
If you know of any other helpful Quick Look tips or tricks using qlmanage or the command line, share with us in the comments below!
А как вы думаете, можно открыть на сайте-блоге раздел или типа того. Там можно будет комментировать самые горячие статьи твоего блога:
[…] Quote from the article: Quick Look is a nice feature added in 10.5, I use it often for glancing at the content of various documents and it certainly beats launching an application. If you’re an avid command line user though, you may be browsing through a directories contents and wondering just what is that JPG or DOC file. Wonder no more, because you can easily use Quick Look from the command line: […]
That is just fantastic! Thanks for that tip.