TUAW reader Shaun Haber sent us a link to his personal blog with a great post about using Leopard's Quick Look from the command line, which is wonderfully handy for anyone who spends a chunk of their day in Terminal. The qlmanage utility gives you direct access to many Quick Look functions; of specific interest is the -p flag. This option displays the Quick Look generated preview for any file. So if you tell it to qlmanage -p foo.png, the image immediately pops up in a Quick Look pane.
Even better, Quick Look supports slide shows. So if you cd into a folder of images and run qlmanage -p *.jpg, you'll be rewarded with a full-on presentation of your pictures.
Other qlmanage flags of interest include -h (displays a help message) -t (thumbnail generation) and -f (a zoom factor to display with).
The downside of qlmanage is that it's full of NSLog-style messages. Haber recommends you pipe the output into /dev/null as follows: qlmanage -p *.jpg >& /dev/null.













Reader Comments (Page 1 of 1)
11-05-2007 @ 2:14PM
kamera said...
why would somebody spend a "chunk of their day" in the terminal??
i'm honestly curious...
Reply
11-05-2007 @ 2:30PM
Micah said...
Kamera: Its called being a programmer dude.
In the words of biggie, if you don't know, now you know ni**a.
Reply
11-05-2007 @ 2:41PM
Brian Reading said...
Great tip! I love how Apple makes things like Spotlight and Quick Look available from the Terminal. They're very useful when shell scripting!
Reply
11-05-2007 @ 2:53PM
Andy Fowler said...
Great tip! For an even easier way to access Quick Look from Terminal, add this to your /etc/bashrc file:
function ql()
{
qlmanage -p “$@” > /dev/null 2>&1
}
Now all you need to do is type in `ql *.jpg` to preview all JPGs. This hides all of the output text of the command, so you don't ruin your scrollback.
Reply
11-05-2007 @ 3:16PM
Joseph Crawford said...
This is a great tip, thanks :)
Reply
11-05-2007 @ 3:25PM
wb said...
Kamera & Micah: not just being a programmer: try being a UNIX systems admin... I live in my terminal.
Reply
11-05-2007 @ 3:32PM
Danny Zumwalt said...
Umm... Is that a picture of quicklook running a slideshow on your iPhone? Do tell!
Reply
11-05-2007 @ 6:01PM
CyBeR said...
Unfortunately it doesn't seem to support full-screen in this way, though.
#7: No, I'd say it's a picture of an iPhone screenshot.
Reply
11-05-2007 @ 6:48PM
Max said...
For some reason, this only shows reduced-size images in quicklook. they're shown with the filename and info on the right, and the small image on the left. Not the same as just selecting the images and hitting Space.
Reply
11-17-2007 @ 11:15PM
zolo said...
Maybe a bit easier to add to ~/.profile or ~/.bash_profile as an alias as follows -- alias ql='qlmanage -p “$@” > /dev/null 2>&1'
You can type "ql *.jpg" and get the same results as above.
Making another "chunk of my day @ the terminal" more enjoyable :-)
Reply