Thursday, March 3, 2011

Very cool feature of OSX to make up for uncool features...

The Finder in OSX is okay for the most part; however, Apple can be a strange mix of the 'well designed UI' approach and the 'keyboard shortcuts rule' approach. Often these approaches complement each other well - sometimes they do not.

One of the things about the Finder I don't like is that there's no path bar or button for simply letting you designate a path. I discovered that there is a 'Go To Folder' shortcut (command-shift-g) which proffers a little dialog box that I can do this with but there's no integrated path bar.

This is certainly an acceptable (mostly) alternative, but I really don't want to have to remember another intermittently used keyboard shortcut (I have several IDE's, Emacs, and different operating systems worth of shortcuts to remember as well, so one less would be nice.)

It turns out, very nicely, that you can add custom buttons to the Finder window simply by dragging an application onto the Finder's toolbar. So, I created a little AppleScript application that simply emitted command-shift-g to most recent finder window, and I gave it an icon. Now my finder window has a little terminal icon (I'll replace the icon later when I have more time) where I can click and it pops up a path dialog to change directories as seen below:



It is the little square black icon just to the right of middle.

Now, to do the same thing you need to open the AppleScript Editor and add the following text to your empty script:

tell application "Finder"
activate
tell application "System Events" to keystroke "g" using {command down, shift down}
end tell


Open a Finder window if one isn't already open and then tell the AppleScript Editor to run the script to verify that it is functioning as expected.

You now want to save the script as an Application - I saved my script into my Applications folder accordingly (you can do what you like.)

Now, you can skip this step if you wish, but I wanted a custom icon (instead of the default script icon) as my button in the Finder window so I found an image that I wanted to use (after looking for about 8 seconds) and opened it. I then selected the portion of the image I wanted and chose 'Copy' (you can use the preview window for this or some other image viewing/editing application.) This placed the image I wanted to use on the clipboard.

In order to change the icon on OSX 10.6.6 I then located the script application and brought up the 'Get Info' dialog on it. I then clicked on the application's icon in the upper left hand corner of the Get Info dialog so that it was selected, I then pasted the clipboard contents which deposited the image into the icon.

The last step is to simply open a Finder window and then drag the application from where you have located it onto the Finder's toolbar and it should appear.

No comments:

Post a Comment