(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Kerio Reseller
Printer Friendly Version

Improving Leopard's QuickLook


2007/12/10

Leopard's new "Quicklook" is a nice tool, but for stubborn old command line types like me, it has some limitations: it won't show me plain text files unless they have the extension ".txt". It's possible that somewhere there's a preference you could add to Quicklook, but I haven't heard of it yet.

There is another way to make Quicklook show "unknown" files: you can mess with the files Info.plist as explained at this MacOSXhints.com 10.5: Add Quick Look support for certain file formats post. But that's really only useful once you realize you WANT to look at the file; I wanted something more automatic.


Hate these ads?

A simple command line script does the job for me. I call it "looky":



#!/bin/bash
qlmanage -p -c public.plain-text "$@" 2> /dev/null &


(I modified that from a MacOSXhints.com post.)

Not much to it, is there? All it does is force Quicklook to interpret the file as plain text. We could make it fancier if we wanted by checking to see if we need to add the "-c public.plain-text", but for my command line use, this is fine - I don't need anything smarter.

But perhaps you do, so here's the "smart" version:



#!/bin/bash
# "smart" Quicklook script by http://aplawrence,com
if [ "$1" = "-f" ]
then
   shift
   qlmanage -p -c public.plain-text "$@" 2> /dev/null &
   exit 0
fi
for file in "$@"
do
   if [ "${file##*.}" = "$file" ]
   then
      qlmanage -p -c public.plain-text   "$file" 2> /dev/null &
   else
      qlmanage -p   "$file" 2> /dev/null &
   fi
done


That let's us add a "-f" if we absolutely want to force the issue. but otherwise uses "ordinary" Quicklook for files with extensions, and forces them to be interpreted as text if there is no extension.

Put this in ~/bin, chmod 755 it, and at a Terminal prompt, use "looky filenames or wildcards" to see it in action.

By the way, on my own system I would not have bothered with all the extraneous quotes around "$file" - the only reason those are there is because of files with spaces in their names, and I would never create such a thing on my machine.


Technorati tags:    

Comments /MacOSX/looky.html


Thu Dec 13 12:27:38 2007: Subject: file names containing space   anonymous
Of course, you could add:





IFS='

'



to deal with the problems about files containg spaces in their names.

Thu Dec 13 12:54:13 2007: Subject:   TonyLawrence
Yes, I guess you could - though to my mind, spaces just do not belong in file names period.. :-)



Add your comments

LOD Communications, Inc.

Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


ad

Views for this page
Today This Week This Month This Year  Overall
92468821 1,184

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

pavatar.jpg
More:
       - MacOSX
       - Leopard
       - Shell




Unix/Linux Consultants


http://thatitguy.com Business networking servers, Linux and Unix experts. In business since 1997! Windows and Exchange to Samba and Scalix migration experts.


http://www.m3ipinc.com Security, firewalls, ids, audits, vulnerability assesments, BS7799, HIPAA, GLB, incident handling


http://www.cleverminds.net Need expert advice? Want a second opinion? CleverMinds is a one-stop-shop for a wide range of technology solutions. We support Unix, Linux, SCO as well as CMS, ecom, blogs, podcasts, search engines consulting and more. Contact us at web2.0@cleverminds.net 0r (617) 894-1282


Your ad here - $24.00 yearly!

Twitter
  • May 13 14:07
    So today at the gym I only did rowing, walking and leg lunges. We'll see how my neck is tomorrow.
  • May 12 16:04
    Hmmm.. think I'm doing something at the gym that is hurting my neck.. not sure what.. I'll have to eliminate something for a few days to see







Coming Attractions

My Favorites

Change Congress

Related Posts