Mac OS X Hints

Contents

As I have just started to use a MacBook, I need to learn many new shortcuts, tricks, and find the right software. Here I'll collect my findings.

Dan Rodney offers a list of keyboard shortcuts, as does Apple itself.

Moving and Resizing Windows

Obviously, I am not the only one who's annoyed by how much work it is to resize or even move windows on OS X. Coming from Linux/KDE, I have learned to love how easy it is to move Windows by just Alt-Dragging them with the mouse pointer anywhere in the Window, or even resizing them (using the right mouse button, again anywhere inside the window).

Fortunately, there are several 3rd party tools which seem to add this behaviour to OS X, too:

To summarize, all solutions I tried feel unnatural, since they're not really integrated into the system. For instance,

Oh, and by the way, I am missing "focus follows mouse" a lot. Some of the above software offers a similar, but totally useless "auto raise" feature - Steve Yegge has written a lenghty blog post on this topic. Despite the useful pointers in that document (and the comments therein), I did not yet find a useful implementation.

Other tools concerned with window resizing / positioning:

Syncing with other Platforms (UTF-8 peculiarities)

When I first tried to rsync data from another machine (running Linux) with UTF-8 filenames, I was surprised to see my files being transferred again and again on multiple runs (actually, I could see rsync deleting them, then immediately re-transmitting, since I used --delete). Then I I recalled discussions on the unison-hackers mailing list about "Mac UTF-8", which is different than other UTF-8.

The full truth is that UTF-8 allows different encodings for some characters, in particular the German umlauts I am dealing with can be represented in decomposed form, e.g. u+" or just as the composed letter ü. Mac defaults to the decomposed form ("NFD" normalized form), Linux (and others) default to the composed form (termed "NFC" variant). More details can be found on unicode.org's page on normalization schemes and on Apples' site.

The main problem is that the HFS+ filesystem implementation changes the 8-bit filename behind one's back! In particular, the filename is converted to and saved as UTF-16, and will be converted back to UTF-8 with decomposed characters when reading from the filesystem. That means that you will not get your exact filenames back that you specified earlier!

Thus, if you (like me) don't want the encoding to be changed on the Linux side, you need to convert the filenames during transfer. rsync has the --iconv switch for this purpose (see their FAQ entry on this issue, and unison also has built-in unicode filename support (which is activated by default in 2.40.x if an OS X system is detected). Also, convmv can be used to fix filenames of existing files; it provides the --nfc / --nfd switches.

My impression is that we need more of this "unicode normalization" in many programs, e.g. ideally a search for "Blätter" should match that word irrespective of the corresponding encoding. Similarly, tab-completion of filenames should be independent of it (note that it is possible - though highly undesirable - on Linux to have two files in the same directory which differ only in the normalization scheme!), and so on.

Mac Keyboard

There are many pitfalls w.r.t. the keyboard:

By the way, I also find it inconsistent that the three-finger swipe gesture for forward/back does not work in the hypertext help windows, which are as similar to Safari as it gets (from a user's perspective).

Jumping to New Mail in Apple Mail

One thing which really annoyed me is that I did not find a keyboard shortcut to jump to my unread messages in Apple Mail. You see - it nicely tells me that there are - let's say 13 - unread messages in folder "Foo", but entering that folder, I am left alone with finding them?!

Fortunately, it is possible to solve this with AppleScript - a quick internet search turns up dozens of AppleScript solutions. As a start, I picked the following:

try
  tell application "Mail"
    activate
    tell the front message viewer
      set unreadMessages to (the messages whose ¬
        read status is false) as list
      if (count of unreadMessages) is not 0 then
        set selected messages to {the first item of unreadMessages}
      else
        beep
      end if
    end tell
  end tell
on error error_message
  beep
  display dialog "Error looking for next unread message: " & ¬
   return & return & error_message buttons {"OK"} default button 1
end try

An appealingly short version is this:

tell application "Mail" to try
  tell message viewer 1 to set selected messages to ¬
    {first message of beginning of (get selected mailboxes) whose read status is false}
  activate
on error
  beep
end try

Dynamic Libraries

(This is mostly only relevant to programmers.) Dynamic libraries often come as "frameworks", which are not linked using -l, but using -framework; the corresponding path flag is -F (instead of -L).

otool -L foo.so is similar to ldd foo.so, and the dynamic linker is named dyld, which is important since the environment variable LD_LIBRARY_PATH is named DYLD_LIBRARY_PATH on OS X, accordingly. See the manpages for otool and dyld (and maybe ld and install_name_tool).

Reading ext2 volumes

Coming from Linux, I have a lot of stuff stored on external HDDs in ext2 partitions, so I am interested in how to read/mount them. There are at least three relevant projects:

An unsolved problem however is that there is no support for filename encoding translation. If you still have partitions using iso-8859-1 (or similar), you will have problems.

Emacs

One of the first things I learned is that X11 apps feel foreign - as you can see above, one has problems with keyboard shortcuts not working, the window being immutable to 3rd party resizing/moving extensions, and the fact that the apps are "wrapped" by an "X11" app is not hidden from the user at all.

So, it is clearly the goal to have pure Cocoa alternatives for all apps you're using. In my case, I was using XEmacs on Unix, and here the situation seems to be that there are only ports of GNU/Emacs for Cocoa (or Carbon), but no maintained XEmacs port. The situation is described on numerous websites, e.g. the EmacsWiki.

Unfortunately, it is non-trivial to port a .emacs from XEmacs to GNU/Emacs. Here are some changes I did:

; XEmacs has a convenient add-path (which supports an 'append option), the closest and shortest
; equivalent that also works on GNU/Emacs seems to be add-to-list:
(add-path 'foo')
(add-to-list 'load-path 'foo')

; Key bindings are specified differently.  In XEmacs, I liked to use
(global-set-key '(meta Y) 'some-func)
; but in GNU/Emacs this nice syntax is not valid.

Some packages are missing; for now I commented them out:

Finally, I have the problem that Alt-5/6 does not give me brackets in Emacs, but "M-5/6" prefixes in the minibuffer. I wonder how other people use Emacs on OS X - that would be unusable, no?!

Other Software I plan to look at


Valid XHTML 1.0! Valid CSS!
This page was last modified: Tuesday, November 09, 2010 hacker emblem