Wednesday, November 19, 2008

Open in Terminal (4 Ways)

One of the cool little helpers I talk about in The Productive Programmer is "Command Prompt Here" or "Bash Here": little context menu items for Windows that allow you to select a folder in Explorer, right click, and open a command prompt (or bash shell, if you are using Cygwin) at that location. Someone recently asked me if you can do this on the Mac, and it turns out you can, in a surprisingly large number of ways.

The first way leverages Automator to create a little script that makes an Automator plug-in for Finder. This trick appears here. The cool thing about this tip is the stuff it teaches about building Finder extension via Automator, which is a pretty cool subject unto itself. However, the bad thing about the final solution proffered by this tip is the location where the context menu appears: 2 levels down in the right-click menu, under Automator. Too much clicking.

Not being satisfied with the above, I found an alternative, which creates a toolbar icon at the top of Finder that opens the current selected folder (or the folder of the currently selected file) when you click on it. This trick appears here. The only downside of this version is the number of windows it spawns: one per request, instead of opening new tabs (it was created before Terminal supported tabs in Leopard). So, not to be outdone, the author describes the steps to upgrade it to tabbed terminal in Leopard here. One gotcha exists in his instructions: he says to replace the original script with the one found on this page, but I assumed you could do that with a text editor. It turns out that you need to use the script editor that launches when you double-click the main.scpt file. Otherwise, it works like a charm.

The reason I haven't pursued this before on the Mac? I generally use PathFinder, which includes not only a context menu for "Open in Terminal", it also has an embedded Terminal, which opens in the current folder. Highly recommended, but it you don't want to spend the money, you can get the same effect by harvesting the links in this entry.

Tuesday, August 19, 2008

The New Backup Strategy

Before Leopard, I had a specific backup strategy for both my volatile content (things like source code, documents, etc) and my entire hard drive, which was a snapshot backup. The volatile documents solution was Subversion, kept on a remote, universally accessible machine. The snapshot backup was handled by SuperDuper, which backs up your entire drive in a bootable state, essentially creating a complete snapshot of your hard drive. A couple of problems reared up because of this setup.
  1. I had to handle the "package" files (the ones created by Apple iWork, like Keynote and Numbers) files specially, because Subversion didn't like the way the applications managed the contents. Basically, I had to zip/unzip them for version control. This wasn't terrible (I automated the process to a large degree), but still a little annoying.
  2. My Subversion repository was huge, because I had my entire Documents folder in it. However, most of the documents were there just so that I could have a backup, not because I wanted to version them. The only files I really versioned where the source files and related content.
The advent of Leopard and Time Machine changed my strategy. First, I separated out the Documents stuff for which I really only wanted backups and let Time Machine handle them. I put all my versionable files (like source files) in a new, much smaller Subversion repository. And, even though I have Time Machine, I still use SuperDuper to create backups. The reason I use both:
  • I want the hourly, behind the scenes backup provided by Time Machine.
  • I want to be able to browse backwards in time to look at previous versions of those files, and the Time Machine UI is gorgeous for that.
  • Time Machine alone isn't sufficient. To restore from Time Machine, you have to boot your machine from a startup disk, then restore the backup. Yuck! I still like SuperDuper's snapshot approach, which I've proven to myself works flawlessly (see Don't Crack Open Your Mac for the story).
  • SuperDuper and Time Machine can share the same drive, so I have a single 500 GB drive that has all my backups on it.
  • It's now easier to replicate the source code in more places (IOW, more machines) because it's much smaller.
  • You can tell Time Machine to only backup certain directories (or, more specifically, exclude directories you don't want backed up). Because I only use Time Machine for my Documents folder, it takes only a little space.
  • Because SuperDuper creates a bootable drive image, and my external drive is FireWire, I can boot another MacBook Pro with the external drive. Yes, it's slow, but if the worst happened while on the road, and I've got to present at a conference, as long as I can borrow/steal another machine, I can boot into my machine from backup and do my presentation.
I've been using this approach for a while, and it works nicely. I leave the external hard drive hooked up all the time, and start a snapshot backup at bedtime every night. SuperDuper has a nice option that will sleep the computer when it's finished it's work. So far, this it working out really well. I haven't had to restore the whole drive from SuperDuper yet on this machine (but I know that works -- I've done it on other machines), and I have used Time Machine to grab a file that accidentally got deleted.

Monday, August 11, 2008

Keyboard Zoom

This is a re-blog from Jack Dempsey, setting up a keyboard shortcut to Zoom.

This works well because almost all Mac applications include the Zoom menu item on the Window menu.

Thanks, Jack.

Thursday, August 7, 2008

Quick Blank

This was left by Emilio as a comment to the Quick Sleep entry from before, but I'm afraid not enough people read the comments so I'm promoting it to full-blown entry.

The keychord CTRL-SHIFT-EJECT instantly blanks the screen, without invoking the screen saver. It's just instant blank. Note that it will not lock the screen if you have passwords turned on for the screen saver, it just makes the screen blank. Still, pretty cool.

Saturday, August 2, 2008

Keynote Mode for Keynote

Several people have asked me how to turn on Keynote mode in Keynote. Keynote mode is where the presenter sees a different view from the audience. In Keynote, you can set up a mode that allows you to see the current slide, the upcoming slide, the time of day, the elapsed time from when you showed the first slide, and the "ready to progress" bar (a red/green bar at the top of the screen that lets you know that all the transitions have completed successfully). To get Keynote mode to work, you must set a particular set of options in Keynote preferences, and getting the combination is just rigth is tricky (especially if you aren't connected to a projector). To show the magic combination, here are the settings I use. First up, the Preferences dialog that controls what you (the presenter) sees:



The other settings appear on the the Slideshow Preferences dialog, shown here:



This is the dialog that controls Keynote's projection options. The important options here are the Allow Epose, Dashboard, and others to use screen, which allows you to see the mouse cursor and interact with the screen even when slides are showing, and the Present on secondary display, which uses the projector (i.e., the external monitor) to show the slides.


There are a couple of caveats to using Keynote mode. First, you must un-mirror your display (found on Display Preferences, under System Prefereces). I usually use the option in Display Options to place them on my menu bar, so that I have easy access to the Display Prefereces. When you un-mirror your display, it is exactly the same as using an external monitor. That means that you can't really do code demos and such unless you want to look over your shoulder. That's why most of my slides how have source code embedded on the slide, so that I can use Keynote mode.

Wednesday, July 23, 2008

Quick Sleep

Here's a quickie, but I showed this to Venkat, and it made his day, so chances are good that others don't know about this handy keyboard shortcut. I used to always rely on my PowerBook to go to sleep successfully when I close the lid. But every once in a blue moon, something doesn't work right, and I open my laptop bag to a red-hot laptop. I suspect that it's latch related (and several other folks have suggested that this was the case). Now, I've taken to putting my machine to sleep before closing the lid. There are of course a variety of ways to do that; my recent common one was to hit the power button, which gives you the shut-down options dialog, and sleep is one of them. That's what Venkat's been doing.

But I recently ran across a better combination: Apple-Alt-Eject provides instant sleep (the Eject key is the one that ejects CD's, just above the delete key). One keyboard chord, and I have a sleeping laptop. I love it when I can cut a 2-step process down to a single keychord!

Thursday, July 3, 2008

Mmmmmmmm...Fresh Apps

One of my ThoughtWorks colleagues turned me on to this one. Most Mac OS X applications check for updates on startup (so many, in fact, that I'm surprised when I let something that doesn't do this get out of date). But each application has to do this on their own. That's where AppFresh fits. From the site:


AppFresh helps you to keep all applications, widgets, preference panes and application plugins installed on your Mac up to date. All from one place, easy to use and fully integrated into Mac OS X. AppFresh works by checking the excellent osx.iusethis.com for new versions and lets you download and install available updates easily.


Not only does it find the applications you need to update (which they mostly do themselves...mostly), AppFresh also handles the chore of downloading the DMG file, extracting it, mounting it, installing the application, and unmounting. No muss, no fuss. You just tell it to update an application and Voila...it's updated.