A very nice new toy recently landed on my desk at work, an Apple MacBook. It's my first Mac and I'm very impressed so far. One of the things I want to use it for is hacking Perl whilst on the move.
To get a
# sign on the MacBook keyboard you use the Option (or Alt) key + 3. This seems terribly klunky to me, and
# is of course used quite a bit in Perl. The other problem is that you might have the Alt key mapped to something else in a Terminal application.
This hack remaps another key on the keyboard to produce the
# character. I chose the funny squiggle that's to the left of the number 1 key (§). This is the Section sign, used in document formatting. Just create a file at
~/Library/KeyBindings/DefaultKeyBinding.dict that contains the following:
/* this will make all § turn into # */
"\UA7" = ("insertText:", "#");
Any app that uses Apple's Cocoa interface widgets for text input will pick this up after being restarted. There are some that don't (perhaps TextMate? Not checked that one so if you know, please comment).
A lot more information about this is available at this excellent page on the Cocoa Text System, including some other neat hacks. Enjoy!