Published on MacDevCenter (
 See this if you're having trouble printing code examples

O'Reilly Book Excerpts: Mac OS X Power Hound, Panther Edition

Mac OS X Power Hound Helpful Hints, Part 2

by Rob Griffiths

Related Reading

Mac OS X Power Hound
Teach Yourself New Tricks
By Rob Griffiths

Editor's note: Last week, in part one of this two-part series or excerpts, Mac OS X Power Hound author Rob Griffiths shared eight of 16 hand-picked favorite OS X hints. This week, Rob shares his knowledge on creating a smart iPhoto album for general searching, using Internet shortcuts, creating a disk image from a directory in the terminal, and more.

Tip 9-19. Create a Smart iPhoto Album for General Searching

iPhoto includes the ability to add keywords to photos--assigning "Aunt Hilda" to all of your aunt's pictures, for example--so that you can find them quickly with a future keyword search (or even a smart album based on keywords). Sure, that's convenient, but what if you want to find the one photo out of your 23,250-picture collection that you named "Secret to success?" Amazingly, iPhoto 4 lacks a basic search feature, which means you're left to browse for the proverbial needle in the photostack.

iPhoto basic search tool

Luckily, you can use smart albums to fake your own basic search tool. Select File -> New Smart Album, or just hit Command-Option-N. iPhoto displays the smart album creation sheet. As seen at left, set the first criterion to search on Any Text (using "contains"), and add a few Keyword criteria if you wish (they're not required). When you're done, click OK. Once saved, you can easily find a photo whenever you want. To conduct the search, just Control-click the saved smart album, select Edit Smart Album, and modify whichever criterion you'd like. To find the missing "Secret to Success?" photo, for instance, just enter the photo's name in the Any Text box, and click OK. (The Any Text function searches photo names, roll names, dates, comments, and keywords.) The Keyword fields you added can be used to help refine your search further. Namely, when you enter a keyword value, iPhoto narrows down the smart album to only those pictures that match the keyword.

Tip 10-11. Setting Identical Window Sizes in iCal

iCal lets you view your calendar by day, week, or month. It also remembers the window size for each mode independently, since Day probably doesn't require as much real estate as Month. Nevertheless, you may find the size change distracting when you jump from one mode to another. Yes, you could take the time to drag all three windows to the same size--just make sure you've got half an afternoon and a bottle of Advil handy before you start. A more precise way to create three identically sized windows is to edit iCal's preferences file. Here's how:

  1. Set the Day view window to the size you'd like to use for all three views, and then quit iCal. Behind the scenes, you've just implanted certain window dimensions in iCal's preferences file.
  2. In the Finder, open your Home -> Library -> Preferences folder. Find the file called and drag it onto the icon of TextEdit. You may wish to make a copy of the file first and save it to your desktop--just in case something goes awry. In the text file filled with code that now opens before you, look for the first <dict> tag a few lines from the top. Just below that, you should see something like this:

    <key>1-day view window rect</key>
    <string>{{640, 265}, {846, 742}}</string>

    The text between the <string> tags will probably be different on your machine, because it reflects your window size and location.

  3. Carefully select and copy the text between the <string> and </string> tags. Press Command-C, for example.
  4. Find the <key>7-day view window rect</key> line further down in the file. Directly below that, replace the text between the <string> tags with the stuff you just copied in the previous step. That is, select the text you want to replace, and then press Command-V to paste. You've just set the Week view window to the same size as the Day view window. If you use the other day views, change those as well.
  5. Find the <key>monthly view window rect</key> line. Once again, replace the text between the subsequent <string> tags with the stuff you just copied in step 3. You've just set the Month view window to the same size as the Day view window.
  6. Save the file, quit the text editor, and then reopen iCal.

You now have identically sized windows in all three views.

Tip 11-13. The Graphing Calculator and Other Hidden Modes

The Calculator has but two modes, Basic and Advanced--or so it would appear. However, with a very simple change in the Finder, you can enable not one, not two, but three new modes: a graphing calculator (as seen below), an expression sheet for entering long calculations, and a hexadecimal calculator for the programmer types among us.

  1. Quit Calculator, if it's running, and switch to the Finder. It's always a good idea to quit a program before you modify it.
  2. Click once on the Calculator icon in the Application folder, and choose File -> Get Info. Command-I does the same thing from the keyboard.
  3. Click Add, and navigate to Applications -> Calculator -> Contents -> Resources in the dialog box that opens. If your dialog box is in list-view mode, you might find it easier to navigate if you switch to column-view mode first. To do so, click the button in the upper-left corner that looks like three vertical bars.
  4. Select ExpressionSheet.calcview, Graphing-2D.calcview, and Hexadecimal.calcview in the dialog box. Click Choose. It's easiest to select these items--without selecting anything else--if you hold down Command while clicking them. Once you've clicked Choose, you should see all three new plugins listed in the Plug-ins pane of the Info window.
  5. Close the Info window and relaunch Calculator.

You'll now see all three new modes listed in the View menu.

Tip 12-11. Internet Shortcuts

In most browsers, you can put about ten of your favorite sites (or folders of favorite sites) on your personal toolbar. But if you have enough favorite sites that you can't remember where you've filed some of them, Internet shortcuts can save you a lot of frustration. An Internet shortcut is a short name that you assign to any web site. When you type the short name into the address bar and press Enter, your browser loads the full URL for you. So instead of typing "" or mousing into your News -> World -> Current folder, you could just type "nyt" and press Enter to call up the New York Times site. Shortcuts (also known as keywords) are supported in every Mac OS X browser except for Safari, iCab, and Internet Explorer.

As a general rule, you must bookmark a page before you can add a shortcut for it. Once you've done that, the process of adding a new shortcut varies slightly from browser to browser:

From now on, you won't have to hunt through subfolders just to find a URL--instead, you need only type your shortcut and press Enter to load your favorite page.

Note: How you remember your shortcuts is another matter entirely. One way is to use a translucent, floating Stickies note so you can see all of your shortcuts, but still see the windows underneath.

Tip 13-23. Force Adobe Help Files to Open in Another Browser

Adobe's help files are factory-set to open in Internet Explorer, one of the oldest and least powerful of the Mac OS X browsers. If you'd rather have the help files open in a more modern browser, there are a couple of ways to do it:

Tip 14-7. Can a Butler Help You Use Your Computer?

It certainly can help you if it's Butler, the productivity assistant for Mac OS X, that you're talking about. Butler isn't a tool for the faint of heart; due to its power, its configuration interface would probably intimidate even Steve Jobs. However, if you spend a bit of time learning its intricacies, you'll find it combines several separate tools into one useful do-it-all application. In a nutshell, Butler is a program that contains the following: a keyboard program launcher, multiple clipboard utility, Internet search tool, customizable Apple menu, application switcher menu, iTunes keyboard controller, customized pop-up menu, and keyboard macro tool. Amazingly enough, though, the above list is just scratching the surface of Butler's capabilities. For instance, if you use Fast User Switching to toggle among a few users on your machine, you know that you lose some menu bar space for the display of the current user's full name. If your name happens to be Richard Brockenstiltzer Tharnborough III, Esq., it's even worse, as you quickly realize that you don't even have a menu bar any more. Fear not, Richard and other similarly long-named Mac OS X aficionados: Butler makes it possible to recapture that lost menu bar space! As shown in the figure above, you can replace a huge menu bar name with a simple pop-up menu.

Tip: To reclaim Fast User Switching's wasted menu bar space, start by disabling Fast User Switching in System Preferences -> Accounts -> Login Options. Then use Butler to add a new Fast User Switching Smart Item, and assign it a keyboard shortcut (Control-Command-F, perhaps). Now, when you need to switch accounts, just hit your new keyboard shortcut. When you do, you'll see the handy pop-up menu shown in the screenshot above, allowing you to fast user switch without any wasted menu bar real estate.

If you're the ultimate power user and don't mind working through a somewhat complex configuration panel, you may just find that adding a Butler to your Mac is the best productivity improvement out there.

Tip 15-85. Customizing Terminal's Welcome Message

When you open Terminal, it displays a friendly "Welcome to Darwin!" message every time (Darwin is a reference to the particular flavor of Unix that Mac OS X uses). You might prefer to have it say something more meaningful or entertaining, though, like "Cower in Fear, All Ye Who Enter Here." The trick is to edit the file /etc/motd, using the pico editor (or your favorite text editor). Because Mac OS X officially owns this file, however, you're not allowed to edit it--unless you blast past the security by using the sudo command. The complete command, then, is this:

sudo pico /etc/motd

Enter your administrative password when asked. Then replace the stock wording in the file with a message of your choice, and save your changes. Now you can connect to "Tina's Terrific G5 Tower of Terror!" instead of Darwin.

Tip: In today's age of hackers, constant Internet connections, and big litigation over very small things, you may wish to consider a warning message, too. Something like this might do nicely: "This computer system is private. Unauthorized usage is strictly prohibited, and all activity is logged. If you are here by mistake, please close your connection window now." While this message may not do much to stop a hacker, it may be useful if you were to ever reach litigation with someone who had hacked your system.

Tip 16-5. Create a Disk Image from a Directory in the Terminal

Create a Disk Image from a Directory in Terminal Apple's Disk Utility program, located in Applications -> Utilities, lets you create disk images. But to create a disk image from a folder, you need to dig into its menus, which can be an annoyance if you're a true speed demon. Luckily, you can accomplish the same thing from the command line. Here's how you can do so from Terminal, using, as an example, your Sites directory.

  1. First, you need to find out how much disk space the directory holds:

    du -s ~/Sites
    10432 /Users/kirk/Sites

    The du -s command returns the number of sectors for the directory. This information tells you how big the disk image must be. In the above example, there are 10,432 sectors. Add about ten percent to this number to account for metadata; this rounds up to 12,000.

  2. Now, create the disk image file:

    hdiutil create -sectors 12000 -fs HFS+ -volname Sites ~/Sites

    This command creates a disk image called Sites in the current working directory. The disk image is formatted in HFS+ format and has 12,000 sectors.

  3. Next, mount the disk image file:

    hdiutil mount Sites.dmg

    You can check in the Finder to make sure it's mounted on the Desktop.

  4. Copy the contents of the directory to the disk image. Use ditto and the -rsrcFork option to maintain any resource forks that may exist:

    ditto -rsrcFork ~/Sites /Volumes/Sites
  5. Now that you're finished, you can unmount the disk image:

    hdiutil unmount /Volumes/Sites

Note: Although this process takes a few more steps than the method in Disk Utility, you can automate these Terminal commands with a shell script to make things move faster next time. Plus, the command-line method lets you create disk images over a network using ssh.

Rob Griffiths is the creator of the Mac OS X Hints site, a database of over 3,500 tips on using OS X.

Return to

Copyright © 2009 O'Reilly Media, Inc.