QuickLook scans file contents before you open those files. Usually this just lets you view a file quickly. But you can also use this same technology from the command line to bring about a change to the Finder without actually opening a file. To access QuickLook from the command line, use qlmanage.

qlmanage -p ~/Desktop/MyTowel42.pdf

While open, click the space bar to go back to your Terminal session. The most notable use case here is that when you use qlmanage you don’t run the risk of changing the date/time stamp of the files.

Lion brings with it a few challenges for administrators. One such is migrating the wiki service into the new format. When doing an upgrade in place, the Wiki service is pretty straight forward to upgrade, but in many cases, due to aging hardware, wiki services are moving from an older computer to a newer computer. This can be done in one of two ways. The first is to “migrate” the data by copying the Collaboration folder onto the new system. The second is to “export” and “import” the data. I usually recommend doing a migrate where possible, so we’ll start with that method.

Note: Before getting started, make sure that the directory services side of things is good. If a user or group lookup for an object that owns, edits or has commented on a wiki fails then that wiki probably shouldn’t be migrated. Use the dscl or id commands to confirm that lookups are functioning as intended.

To migrate wikis from one server to another, first copy the Collaboration directory to the new server. In this example, the directory has been dropped onto the desktop of the currently logged in user. To migrate the data once copied, use the wikiadmin command, along with the migration option. The option requires the path to the Collaboration folder, defined with -r, as follows:

sudo wikiadmin migrate -r ~/Desktop/Collaboration

When moving wikis, you can take the opportunity to get rid of a few you don’t want (such as that test wiki from way back when). Or administrators may just choose to move a single wiki to a new server in order to split the load across multiple hosts. When doing so, use the same command as earlier, along with the name of each wiki that is being moved, along with the -g option. For example, if moving the Legal wiki:

sudo wikiadmin migrate -r ~/Desktop/Collaboration -g Legal

The second way of moving wikis around is to export and then import them. To do so, first export wikis on the old server, using the wikiadmin command along with the export option, which requires an –exportPath option and needs to be done, on a wiki-by-wiki basis. So to export that Legal wiki to a file called LegalWikiTMP on the desktop:

sudo wikiadmin export -g Legal --exportPath ~/Desktop/LegalWikiTMP

Next, copy the wiki to the new server and import it, using the import option along with –importPath to identify where the file being imported is located. Using the same location, the command would then be:

sudo wikiadmin import -g Legal --importPath ~/Desktop/LegalWikiTMP

Note: The ability to import a wiki also allows for an API of sorts, as you can programmatically create wikis from other sources. The ability to export also provides a way to move into another wiki tool if you happen to outgrow the options provided in OS X Server and need to move to something more robust.

There is another way to move wikis, using pg_dump, copying the data and then using pg_restore to import the data once you’ve created the tables. This way is, in my opinion, the last resort if the standard wikiadmin commands aren’t working. In my experience, if I’m doing the migration this way then I’ve got other, bigger issues that I need to deal with as well.

These commands work best when the wiki service has been started so that the databases are fully built out. To start the wiki service from the command line, use the serveradmin command instead of the wikiadmin command. The serveradmin command is used with the start option and then wiki is used to indicate the wiki service, as follows:

sudo serveradmin start wiki

The service can also be stopped, swapping out the start option with a stop option:

sudo serveradmin stop wiki

Finally, in a few cases (this is the main reason I’m writing this article), the attachments to wikis don’t come over during a migration. To migrate the files that are used for QuickLook, downloading attachments, etc, use the serveradmin command to locate the directory that these objects are stored in:

sudo serveradmin settings wiki:FileDataPath

The output identifies the directory where these objects are stored. Placing the contents in the same relative path as they are to the output of the same command on the target server usually results in restoring them. Once moved, use the fixPermissions option to repair the permissions of any files from the source (if any changes to account IDs are encountered such as an export/import rather than an archive/restore in OD this can lead to odd issues:

sudo wikiadmin fixPermissions

Also use the rebuildSearchIndex option with the wikiadmin command to fix any indexing, once the permissions have been repaired:sudo wikiadmin rebuildSearchIndex

And finally use resetQuicklooks to clear any cached Quicklook representations of objects that have been inserted into a wiki and might not display properly using Quicklook (you know you might need to do this if they look fine when downloaded but look bad with Quicklook even though QuickLook on the server can view the files just fine):

sudo wikiadmin resetQuicklooks

When done properly the migration can take awhile. Keep in mind that every tag, every article, every edit to every article and basically everything else is tracked inside the tables that you’re moving. While there might not be a ton of data in the Collaboration directory or in an export, all of the data needs to go to the right location. This can take a little time in environments that have a lot of articles, even if they’re really short articles…

You’re searching for some content on your desktop and opening pages file after pages file and pdf after pdf in QuickLook. Finally you find that one juicy morsel. It’s a short script you just need to copy into your clipboard. But you can’t. The gods of technology are aligned against you, to make you hit command-O and then after waiting for the entire 3 seconds it takes Preview to open, you have to search within the document for that information. Holy crap, you just lost at least 5 to 8 seconds of your day. I guess now you have to cancel vacation or let your spouse know you’ll be home late late.

But you don’t have to miss the train. I have a step in my imaging workflow that you’re going to love. One of those little gems I put in my default user and had almost started thinking was the default until I realized it was part of my imaging workflow during ML upgrades. Gain back at least 10 seconds a day with this handy little option: enable text selection in QuickLook. Basically, if you click on text in QuickLook nothing happens, double-click the file to open. If you write the QLEnableTextSelection key into com.apple.finder (.plist) then log out, reboot or kill the Finder, you can click on text and it actually highlights (cue angelic chorus):

defaults write com.apple.finder QLEnableTextSelection -bool TRUE

And to kill the finder:

killall Finder

To undo:

defaults write com.apple.finder QLEnableTextSelection -bool FALSE

Now take that extra hour a year I gave ya’ and sumbit an article to this site using the Submit button in the toolbar!

It’s fairly easy to take an application installer in Mac OS X and repackage it. In the process it’s also straight-forward to include other, potentially unintended information in the package. This is why a number of vendors will sign their packages and then post the signatures for systems administrators to be able to verify the signatures. In Mac OS X you can also view the contents of a package by control-clicking on it and choosing Show Contents in order to be able to manually review the contents. But could it be even easier? Apparently so: Mothers Ruin Software has written a QuickLook plug-in for Packages, called aptly enough, Suspicious Package. Suspicious Package will show you the contents of a package in a screen that also tells you whether the package will require a reboot, require elevated privileges and even if it contains any scripts – and all at the press of a spacebar when clicked on an item.

If you click on a file, folder or image in Mac OS X and then press the space bar to see a QuickLook screen. Here, you can click on the diagonal arrows pointing outwards to move into full screen – great for showing documents or images during presentations. While in full screen mode, click on the diagonal arrows again to go back to a windowed appearance. If it is an image then you can will also have an icon to save the image into iPhoto and can option-click on the image to zoom in.