The Hunting of the Snark


category: encategory: maccategory: tech created: 9. May 2005
modified: 19. May 2005
canonical: http://snark.de/index.cgi/0006

Adapting Mac OSX Tiger

I just got a fresh copy of Mac OS 10.4 (aka OSX Tiger) and installed it on a spare partition of my PowerBook. But the alleged 200 new features left me fairly unimpressed after a weekend of playing around with it.

The dashboard looks cute - but i fail to see, what i would actually use it for.

And spotlight? Leave me alone! While the underlying technology may be great, the presentation is stupid - at best! Who needs another weird UI Element in which selecting a Menu Item (the spotlight icon in the top right corner) pops up an input dialog where you would expect a submenu... Where is the much praised Apple UI consistency?

Also, missing a way to ask at least semi-boolean queries that contain OR-ed components make it next to useless for me. The fact, that the result list pre-groups the finds for me in a way that is allmost allways contrary to what i currently need... Pah!

The underlying indexing and feature extraction technology looks sound however and i hope, third party add ons will soon make it actually usefull.


But what i really wanted to write about is, what i had to do to make Tiger behave like my old Panther setup again: Instead of upgrading or importing my old settings automagically, i chose to make a clean install and see, which of my weird configs i actually needed. Here is, what i installed first:

my Terminal.app setup:
I just copied over my .profile and .inputrc - then i already felt mostly at home. Most of .inputrc is needed to get bash to scroll thru the history properly (for my definition of properly: if i type the start of a prevoius command and then use the cursor-up key, i want to see prevoius commands that started with what i just typed...):

# bash profile:
alias ls="/bin/ls -G "
alias ll="ls -l"
alias la="ls -a"
alias lla="ls -la"

shopt -s histappend
HISTFILESIZE=1024
HISTCONTROL=ignoreboth

export EDITOR='emacs -nw'
export LESS="-i"

export HST=`hostname -s`
export PS1="[\u@${HST} \W] \`if [ \$? = 0 ]; then echo :\\\); else echo :\\\(; fi\` "
export PROMPT_COMMAND='echo -ne "\033]2;${USER}@${HST}:${PWD}\007"'

test -d ~/bin && PATH=$PATH:~/bin
# .inputrc
# keypad mode
"\M-OA": history-search-backward
"\M-OB": history-search-forward

# ansi mode
"\M-[A": history-search-backward
"\M-[B": history-search-forward

#8-bit keypad:
"\M-\C-OA" history-search-backward
"\M-\C-OB" history-search-forward

# 8-bit ansi:
"\M-\C-[A": history-search-backward
"\M-\C-[B": history-search-forward

set completion-ignore-case on
set page-completions off
set show-all-if-ambiguous on
set meta-flag on
set convert-meta off
set output-meta on

Keyboard fiddling:
Next i just needed to get my keyboard setup back... And that's harder than it sounds. I am used to typing with a german keyboard layout on a wintel box. When you do some programming or use the shell a lot, that means, the mac is a completely different beast. the pipe, the @, square and curly braces, the tilde, ... everything is different. So i had made great efforts to get everything working the way i wanted it with panther. Also, i am very much used to emacs shortcuts everywhere - and Mac OSX supports them almost everywhere - but to actually use them, i needed a lot of fillding.

germanalt.gif First things first: on the left, you see the original german mac setup: the characters you get while holding down the alt or option modifier. The orange ones are so called deadkeys: if you want the actual character (e.g. a tilde by typing alt+n), you have to follow up the keystroke with a space. otherwise, it will decorate the following character and alt+n followed by n becomes ñ.

hhalt.gif On the right, you see my modified layout: The green keys are the ones i mistyped all the time because my motoric memory expects them to be in the green places!

You can download the download deutschpc.rsrc modified keyboard layout (2.6 K) and drop it into your ~/Library/Keyboard Layouts folder (create it if it does not exist). On the next login, you should be able to select DeutschPC in the SystemPreferences International tab.

Next are the emacs keybindings:
Emacs knows a lot of handy shortcuts for jumping around in text and altering it. Since i got very used to these, i am happy that OSX supports some of them -- at least in Cocoa Applications. Read more about this in Apples Developer Docs You can drop my download defaultkeybinding.dict defaultkeybinding.dict (1.0 K) into your ~/Library/KeyBindings Folder (create it, if it does not exist) to activate some more of the emacs keybindings in Cocoa Applications emacs and the shell know about them already. However, this is, where it really gets messy: Some of them are not Control-Key sequences, but rather META-Key Sequences - only the Mac does not have a Meta Key...

In the old Unix days, The META modifier was signalled by setting the eighth bit on a character - but since then, a lot has happened and people actually want to type more than std. ascii characters - at least me! The Alternative has allways been to preceede the Meta-Key sequence with an escape character instead of setting the eights bit. So META-f can either be sent to an application by setting bit 8 in the caracter 'f' (that would be a ligature ae in ISO-Latin-1 and an invalid sequence in UTF-8) or by sending an escape (ascii 27) followed by the letter f. Emacs and most shell tools know how to handle this. The defaultkeybinding.dict from above also knows about it. Only i can't be bothered to actually reach for the escape key every time.

Terminal.app has an option to use alt as a meta key - but that uses the old way of setting bit-8 and it won't help me, if i ever want to type german umlauts or anything else that is not std. us ascii...

So i went ahead an actually patched around in Apples Keyboard drivers!

That's right: You can get the source code to all the usual low level drivers at http://www.opensource.apple.com/darwinsource/ if you are a (for free) registered apple developer and a little bit later the will appear on http://www.opendarwin.org/ for access without registration.

I got myself the Tiger-Version of the ADB Keyboard Driver (AppleADBKeyboard-238.3.4) and hacked away in XCode. My current setup uses the obnoxious enter key (between the cursor keys and the right command key) as the alt modifier (you can do that without a compiler by just fiddling with info.plist) and turns the original alt-key on the left onto a META key that sends escape in front of every other key as long as it is pressed (for this one, i needed to replace /System/Library/Extensions/AppleADBKeyboard.kext with an actual modified binary).

Now i can actually type ahead blindly without thinking twice. Contact me, if you are interested in using this too.


(c) Heiko Hellweg 2005 - 2009 top