You are hereBlogs / marv's blog / Leopard Command-Liners: QuickLook
Leopard Command-Liners: QuickLook
If you're like me, you'll be spending most of your time in Leopard in the Terminal, wondering how all the crazy new features affect people like us. Well, here I'll give you a brief overview of how I have been able to put some of Leopard's new features to use. Today, I'll focus mostly on QuickLook.
QuickLook allows (pre-)viewing a large variety of documents system wide, using a plug-in architecture. Together with CoverFlow, going through large collections of media is no longer a hassle (heck, it's fun)! It has already been mentioned that this is great for that hidden porn collection, however it also has some more "creative" advantages. For instance, I have to deal with large image collections on a daily basis. By large, I mean millions. Obviously, I need to do a lot of sorting and grep-ing. With leopard, I can now actually view my results on the fly. For this I use the new qlmanage command. So to view a large set of images with QuickLook, I can do something like
qlmanage -p $(find images -name '*pizza*.jpg') >& /dev/null
And voila, a QuickLook preview of all the images pops up. The piping into /dev/null is necessary, as qlmanage has a lot of debug output. Here you can see a screenshot:
The downside to this method, is that the interface of qlmanage is far from ideal: Keys don't work, images can't be scaled up in the catalog mode, and most glaringly: I haven't found a way to exit catalog mode.
The idea for a better view is similar to that of the new smart folders. We would like to create a smart folder, and view the contents in the Finder using the Cover Flow view. Unfortunately, smart folders a XML files with Spotlight search parameters hidden deep within the Finder application package - hardly usable for command-line junkies. So, to get something similar, we use the good old hard links (also used by Apple extensively in Leopard). We begin by creating a pre-defined directory, for instance
mkdir -p /tmp/QuickLook
and hard-linking a list of input files by
while read ITEM; do ln -f $ITEM /tmp/QuickLook/; done
Then, we open the folder in the Finder:
open /tmp/QuickLook/ && osascript -e 'tell application "Finder" to set current view of window 1 to flow view'
We use these ideas to form a nice little script, called quickview, and now we have a nice way of looking at files from the command-line! Granted, it is a bit of a hack, and I'd be happy for any ideas. Below is a screenshot of the output:
Finally, I'd like to round this entry up with one more cool feature of leopard: I was shocked to see that my cool 'Print Remotely' script, which is a PDF Service I created to print files to network printers at my University stopped functioning. I also had trouble with my X11 application in the dock. Turns out Apple has simplified the use of X11 in Leopard, which is now better integrated into the OS. By simply removing all references to the X11.app in my scripts they began working again. Why? Because it is no longer necessary to explicitly open X11. Try it! Go into the Terminal.app and enter
xeyes &
X11 will automatically open, and display the oh-so-useful eyeballs. This even works when ssh-ing into another shell, and using the -Y option to forward X11 calls. Although this change (and the fact that X11 is now based on Xorg 7.2), causes a great deal of things to break in the new X11, I am optimistic that things will be better in the long run. If not, there is always the option of reinstalling the old X11 from Tiger.
Happy Hacking!
- marv's blog
- Login to post comments
- Login to post comments
- Login to post comments
- Login to post comments
- Login to post comments