Mac OS X Hints
Quickly Access the Sound and Displays Preference Panes
If you’re a laptop user who opens the Sound and Displays preference panes a lot—to change sound input or adjust a secondary monitor’s position, for example—you may be interested in undocumented shortcuts that take you directly to them from any application.
On your iBook or PowerBook, you can open either preference pane by holding down the option key and then pressing one of the volume- or brightness-controlling function keys (for Sound and Displays, respectively). So option-F1 or -F2 will open the Displays pane, and option-F3, -F4, or -F5 will open the Sound pane. If you have a desktop Mac and an Apple keyboard with volume controls, you can hold down option and press any of the volume keys at the top of the keyboard to open the Sound pane. Unfortunately, there’s no shortcut to the Displays pane for desktop Mac users.
Numerically Order Terminal File Listings
Working with numbered files in Terminal is somewhat frustrating because the app doesn’t properly sort the files in directory listings. Consider a simple directory containing 20 versions of a graphic— Logo-version 1, Logo-version 2, and so on. If you use the
ls -1command (which lists one file per row of output) on this directory, you’ll see something like this:
If you’re tracking revisions, or otherwise looking for a file in a large group of files, this manner of sorting can be problematic. However, using Unix’s ability to combine simple commands via the pipe (
|) symbol, you can display files in numerical order, with 2 following 1, and so on.
The key to this trickery is the
sortcommand, which does what its name suggests—it sorts what it’s given as input. Adding the
-noption will sort data numerically.
sortalso needs to know which portion of the data you’d like it to sort by. You direct it by specifying a starting point within the string of text to be sorted, stated in terms of a field number and then a character position within that field. Fields are groups of characters separated by spaces; in this example, there are two fields in the file name. The first field (numbering starts 0, not 1) is the Logo-version portion of the file name (or field 0). The second field (or field 1) is the version number. You don’t need to specify a location number within a field unless you want the sort command to start somewhere other than the beginning of the field.
Putting it all together, to sort the example output in numerical order, you’d type
ls -1 | sort -n +1, which means “print a directory list, send its output to sort, and sort it numerically by the second field.” When you run the command, you’ll get a nicely organized list of your files that begins like this:
You can also use the optional character position for sorting numbered files that are lacking spaces in their names. For instance, for a series of files named ClientStuff1.txt, ClientStuff2.txt, and so on, you’d use the command
ls -1 | sort -n +0.11. Since there are no spaces in the file names, there’s only one field (field 0), and the numeric portion of the file names starts at the 12th character (position 11, since numbering starts at 0).
Move (Don’t Copy) Files between Disks
If you have more than one hard drive or partition in your Mac, you probably know that dragging an item from one volume to another copies it instead of moving it. If moving is what you’re after, you need to copy the item and then delete the original.
An easier way to achieve the same result is to start the process as usual (click and drag the item), but before you release the mouse button at the destination, hold down the Command key. Now take your finger off your mouse, and the Finder will take care of moving the file from the source to the destination—saving you the trouble of removing the original.
Use the Inspector to View Previews
The Finder’s column view is a great way to see a bunch of information about a selected file. You can even play movies and sounds directly from column view. But if you prefer icon or list view, why should you have to give up the benefits of column view?
You probably know about OS X’s Get Info window (Command-I or File: Get Info, with any item selected in the Finder), whose Preview area will allow you to play audio and video files. However, opening a Get Info window for each file you want to preview is time-consuming and wastes screen real estate.
Get Info has a more powerful cousin called the Inspector, which you activate by pressing Command-option-I with an item selected in the Finder. The Inspector looks just like the Get Info window, but it’s dynamic. As you select new files in the Finder, the contents of the Inspector window change to reflect the current selection, so you can easily access previews of all your files while still benefiting from icon- and list-view windows. Just open the Inspector in an unused portion of your screen, and leave it there while you browse. That way, when you want to preview a video or listen to an audio clip, it’s just a mouse click away.
[ Contributing Editor Rob Griffiths is the author of the recently released Mac OS X Power Hound, Panther Edition (O’Reilly, 2004) and runs the Mac OS X Hints Web site. ]Using the Inspector window, you can reap the benefits of column-view windows—with previews of sounds and movies—without having to change from list- or icon-view windows.
Mac OS X HintsNext Page