December 16, 2007

old manpages after 10.5 upgrade

Nasty upgrade bug: if you upgraded OS X 10.4 to 10.5, the installer left your old manpages in place. It also added the new ones, gzip compressed, but man finds the old ones first.

The summarized fix:

find /usr/share/man -exec test -e {}.gz \; -exec tar rzvPf ~/man.tgz {} \;
sudo find /usr/share/man -exec test -e {}.gz \; -exec rm {} \;

Your 10.4 manpages will be backed up to ~/man.tgz and then removed.

If you have a case-sensitive file system, see the comment by sEEKz on the hint page.

posted at 08:11 -07:00 | os10 | no comments

May 28, 2007

facebook-statuses r66

A couple of small updates to my facebook-statuses script:

  • if there are three or more notifications, they are sticky
  • some network errors are caught and ignored

Download it!

posted at 09:16 -07:00 | os10 | no comments

April 30, 2007

facebook status notifications with growl

Facebook Status with Growl

  1. Download facebook-statuses.

  2. Copy the “Friend’s Status Updates” link from your Facebook status page. It should look like

  3. Run the script with the URL you copied as the first argument: facebook-statuses '' (with your own URL, obvs). A big pile of Growl notifications should appear. The script saves the RSS URL, so in the future you can run facebook-statuses with no arguments.

  4. Automate! Run crontab -e and add */10 * * * * ~/bin/facebook-statuses to run the script every 10 minutes.

It will show an image if it can find ~/Pictures/facebook.png. I used Facebook’s favicon which is okay but too small. Suggestions for a better image are welcome.

posted at 15:10 -07:00 | os10 | six comments

April 14, 2007

backpack calendar and quicksilver

I wrote a little script to post Backpack Calendar events from Quicksilver.

Quicksilver: create event

A Growl notification lets you know if the event was posted properly.

Growl: show event

It’s like QuickPack but it only handles calendar events. I wrote it mostly to learn how Quicksilver actions work. I’m a programmer; I like reinventing the wheel.

Along the way, I fixed a tiny bug with booleans in the Ruby library and kludged around a bug in the API (XML with multiple root elements is sometimes returned).


  1. Download the Backpack Ruby library. Put it somewhere in your Ruby path (e.g., /opt/local/lib/ruby/site_ruby; see ruby -le 'puts $:').
  2. Apply my patch: curl | patch
  3. Put Create Backpack Calendar Event.rb in ~/Library/Application Support/Quicksilver/Actions. If you don’t have an Actions folder, make one.
  4. Restart Quicksilver (⌃⌘Q).
  5. Run Keychain Access and a key called Backpack API. The account name is your Backpack user name. The password is your API token, which you can find on your Backpack account page.


  1. Activate Quicksilver.
  2. Type a period to enter text mode, and then your event text.
  3. Hit tab and then type cal or similar to find the script.
  4. Hit return.

Enter text as you would in Backpack: 4/14 spend Saturday night nerding out.

A word starting with +rem (e.g., +remind and +reminder also work) will turn on a reminder for the event.

The first calendar (“Personal”) is the default. You can post to a different calendar by putting its name in square brackets: [work].

If the Growl notification says “Event post failed”, it’s probably because Backpack doesn’t understand your date or time. Take a look at the examples on the Backpack Calendar.

posted at 21:32 -07:00 | os10 | no comments

April 06, 2007

itunes links


Those little iTunes Store arrows seemed useless until I learned that ⌥-clicking makes the link work within your library. I use them most often to jump from the full library to playing a single album.

To make the links internal by default (with ⌥-click going to the iTunes Store):

defaults write invertStoreLinks -bool true
posted at 21:57 -07:00 | os10 | no comments

January 30, 2007

universal sshkeychain

SSHKeychain was the last PowerPC application on my MacBook, and it was also taking a lot of CPU time. The program hasn’t changed much in the past couple of years because its developer has been too busy with work. A couple of weeks ago he resurfaced on the developers mailing list and co-ordinated a Universal build that also fixes a crasher.

Summary: hooraj!

posted at 10:30 -07:00 | os10 | no comments

December 21, 2006



posted at 10:52 -07:00 | os10 | two comments

November 22, 2006

mutt with imap and ssl on os x


Why use Mutt instead of a pretty graphical mail client? Because it still sucks less than anything else I’ve tried.

Mutt is incredibly configurable, which of course means it takes a long time to set up.


Install MacPorts if you don’t have it.

$ sudo port install mutt-devel +headercache +imap +ssl
$ sudo port install msmtp mailtomutt lbdb urlview w3m

configure Mutt

Add the following to ~/.muttrc. Use your own email address and mail server, obvs.

set query_command="lbdbq %s"  # little brother talks to address book
set text_flowed  # use format=flowed
unset wait_key   # return immediately from external programs
set encode_from  # use quoted-printable for From at the start of a line
unset metoo      # remove me from CC
set edit_headers
set autoedit
set read_inc=100

# imap
set imap_idle
set imap_user=grant
set imap_pass=`security find-internet-password -g -r pami -s 2>&1 >/dev/null | cut -d\" -f2`
set folder=imaps://
set spoolfile=imaps://
unset record         # no sent-mail folder
fcc-hook !(~l|~p) !  # save non-list, non-to-me messages to the inbox
set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies"
set certificate_file=~/.mutt/certificates
set ssl_force_tls
set mail_check=300

# smtp
set use_envelope_from
set sendmail="/opt/local/bin/msmtp"
set from="Grant Hollingworth <>"
set sendmail_wait=-1  # send in background

# 'mailboxes' has to be after 'set folder' for the '+' to work`
# e.g., mailboxes ! +debian-security-announce


Mutt will cache the headers of the mail in each folder you look at, as well as the bodies of all the mail you’ve read.

mkdir -p ~/.mutt/cache/{bodies,headers}

This stuff adds up, though, and Mutt doesn’t delete old headers and bodies. Make a cron entry to delete cache files more than a week old. Run crontab -e and add the following line:

@hourly find ~/.mutt/cache -mtime +7 -mindepth 2 -delete


Mutt doesn’t have SMTP support built in. Instead, it expects a sendmail-style command to be available. You can use Postfix, which comes with OS X, but I prefer to send the mail using, my mail server. msmtp acts like sendmail and sends mail by SMTP over SSL.

Create ~/.msmtprc with the following, adjusted for your own account:

account default
auth on
user grant
password SEKRIT
tls on
tls_trust_file /Users/grant/.mutt/certificate-authority
tls_starttls off
domain has an SSL certificate, but it’s signed by our own certificate authority. To tell msmtp I trust it, I downloaded the authority certificate.

curl > ~/.mutt/certificate-authority

The domain setting on the last line of .msmtprc is a bit of a kluge. By default, msmtp tells the mail server its name is ‘localhost’. rejects potential spam by denying external mail claiming to be local. I used the domain to work around this.

address book

The Little Brother’s Database (lbdb) can search Apple’s Address Book for email addresses. It also knows how to read Mutt’s alias file, Pine’s address book LDAP directories, and more.

Make ~/.lbdbrc:

MODULES_PATH="$HOME/.lbdb /opt/local/lib/lbdb"
METHODS="m_muttalias m_osx_addressbook"

If you want to search for names with accented characters, you need to make your own version of the m_osx_addressbook script.

mkdir ~/.lbdb


#! /bin/bash -posix
# -*-sh-*-
#     Copyright (C) 2003  Brendan Cully <>
#     Copyright (C) 2005  Roland Rosenfeld <>
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     GNU General Public License for more details.
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.


  $libdir/ABQuery `echo "$@" | iconv -f 'utf-8' -t 'macroman'` | grep -ia "$@"

opening links

Copying links and pasting them into your browser gets old after a while. You can’t just click on links in Mutt as in a graphical mail client. The next best thing is urlview, which you can run with ⌃B.


COMMAND open %s

urlview will use open(1) for all links. open will use your default browser.

A lot of mailing lists have headers with URLs in them, which I don’t want to see in the list of links. I made a wrapper to chop them out.


# throw away mail headers to avoid list URLs
ruby -e 'gets until /^\n$/; print while gets' $@ | /opt/local/bin/urlview

For this to work, $HOME/bin should be before /opt/local/bin in $PATH.

viewing HTML mail and images

curl > ~/bin/view_attachment
chmod +x ~/bin/view_attachment


text/html; view_attachment %s html; needsterminal
text/html; w3m -dump -T %t; copiousoutput
image/*; view_attachment %s


alternative_order text/plain *
auto_view text/html

With this setup, Mutt will show the text/plain section of a MIME message with both plain text and HTML. If the message is HTML-only, it will convert it to plain text with w3m. To view HTML in your browser, hit v for the attachment menu, select the attachment, and hit enter.

use UTF-8 uses UTF-8 encoding of text by default, but not all your programs will know that.

add to ~/.profile (or ~/.MacOSX/environment.plist):

export LC_CTYPE=en_US.UTF-8

add to ~/.inputrc:

set input-meta on
set output-meta on
set convert-meta off

Finally, in Terminal’s “Window Settings”, turn off the wide glyphs options under “Display”.

use TextMate to write your mail

Buy TextMate if you haven’t already. It’s really good.

in ~/.muttrc:

set editor="mate -w"

To look up addresses, use the Find Email Address in Address Book command, written by Brett Terpstra and me.

Download and double click it to install. Type part of a name in TextMate and hit ⌃⇧⌘A.

mailto links

MailtoMutt is a simple program that runs Mutt when you click on a mailto URL. It leaves a Terminal window and itself running after you send the message. Ugly, but it’s better than nothing.

Configure MailtoMutt as the default app for mailto links using RCDefaultApp.

posted at 21:53 -07:00 | os10 | no comments

November 10, 2006

delete songs from smart playlist in itunes

⌥⌫ deletes tracks directly from a playlist. I can’t believe I didn’t know about this before… going to the regular library just to delete music was super annoying.

posted at 16:31 -07:00 | os10 | no comments

November 03, 2006

keychain internet password protocol endianness

You can retrieve keychain items using security(1). On my old PowerBook, I was using

$ security find-internet-password -s -r imap \
-g 2>&1 >/dev/null | cut -d\" -f2

On my new MacBook that stopped working. Debugging it was a little annoying because security only returns the first match. I thought it was something specific to the imap protocol… maybe had to do some magic first.

Eventually I changed the server name to “mail2” so I could see what it was returning. It turns out that the protocol isn’t a regular string at all. It’s more like a four-character creator code, stored as an int. And on an Intel chip it’s reversed: pami.

security seems to have all kinds of endian trouble:

$ security find-internet-password -r pami -s
    keychain: "/Users/grant/Library/Keychains/login.keychain"
    class: "teni"
        0x07000000 <blob>=""
        0x08000000 <blob>=<NULL>
        "tadc"<timedate>=0x32303036313130323136313732305A00  "20061102161720Z\000"
        "tadm"<timedate>=0x32303036313130333137353535305A00  "20061103175550Z\000"

New command:

$ security find-internet-password -s -r pami \
-g 2>&1 >/dev/null | cut -d\" -f2
posted at 11:19 -07:00 | os10 | no comments

October 24, 2006

detect displays sekrit code

Sometimes my Tibook thinks it still has an external display attached and that it should blank the main screen. Putting it to sleep and waking it up doesn’t work. Attaching another external display does, but I don’t always have one handy.

Clicking on “Detect Displays” in the Displays control panel works, but that’s hard to do in the dark. For future reference: ⌘-space [Quicksilver], dis↩ [open Displays], ⇥, right, [pause], left, ⇥, ⇥, ⇥, space.

posted at 08:37 -07:00 | os10 | two comments

October 02, 2006

compiling gqlplus on os x

gqlplus is a wrapper for Oracle’s sqlplus which provides table name tab-completion and a shell history.

Update 2007-01-18: gqlplus 1.12, released on 2006-12-02, includes the following changes and compiles easily.

To make it work on OS X (using the Oracle Instant Client) I had to patch gqlplus.c to pass through the environment variables DYLD_LIBRARY_PATH and ORACLE_PATH.

$ patch <<END
--- gqlplus.c.orig      2006-09-19 14:40:12.000000000 -0600
+++ gqlplus.c   2006-10-02 16:47:00.000000000 -0600
@@ -383,6 +383,8 @@
 #define NLS_COMP         "NLS_COMP" 
 #define NLS_SORT         "NLS_SORT" 
 #define PATH             "PATH"
 #define TERM             "TERM"
 #define SPACETAB         " \t"
@@ -1183,6 +1185,8 @@
   enx[idx++] = get_env(NLS_SORT); 
   enx[idx++] = get_env(LD_LIBRARY_PATH); 
   enx[idx++] = get_env(TWO_TASK); 
+  enx[idx++] = get_env(DYLD_LIBRARY_PATH);
+  enx[idx++] = get_env(ORACLE_PATH);
   return enx;

gqlplus includes its own copy of readline, which by default tries to build a shared library of itself. That failed miserably, so I turned it off. The easiest way is to pass --disable-shared to the gqlplus configure script, which will pass it on to readline’s configure.

$ ./configure --disabled-shared
$ make

gqlplus should now work just like sqlplus for connecting to a database.

posted at 17:28 -07:00 | os10 | no comments

September 05, 2006


Before OS X 10.4, I used uControl to remap caps lock to control. I also remapped the mostly useless enter key (on my Tibook, it’s to the left of the space bar) to command. 10.4 added built-in caps lock remapping, and uControl is no longer maintained. Enter went back to being useless, except in TextMate.

DoubleCommand has been around for years, but I just recently found out about it (i.e., bothered to search for it). Now I’ve got my right command key (closed apple?) back. It’s very handy for going back in a web browser, since it’s close to the arrow keys.

posted at 10:39 -07:00 | os10 | three comments

August 01, 2006

apple gripes

Two things I wish they’d fix:

  1. Trusted wireless networks. “No trusted networks can be found. Would you like to join [network that’s already trusted]?”

  2. Preview’s window fit button (or whatever the “+” button is called). It expands horizontally fine, but always shrinks up as though I had the standard fat dock at the bottom. Remembering the zoom setting for each document would be great, too.

posted at 22:00 -07:00 | os10 | two comments

May 17, 2006

rebuild launchservices

If the “Open With” context menu lists applications multiple times (I had three each of VLC, MPlayer OS X, and RealPlayer), you can rebuild the LaunchServices database with lsregister: /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

posted at 09:14 -07:00 | os10 | no comments

May 15, 2006

quicktime vs vlc fight!

After Software Update installed QuickTime 7.1, movies embedded in web pages stopped working. Instead, I saw a black box with the label “(no picture)”.

Removing VLC Plugin.plugin from /Library/Internet Plug-Ins fixed the problem.

posted at 13:03 -07:00 | os10 | no comments

September 19, 2005


The new version of SafariStand adds OmniWeb-style graphical, rearrangeable, tabs in a sidebar. It also has a (somewhat clunky) interface for per-site settings, such as font size and pop-up blocking. OmniWeb does that automatically. I’m not sure why Safari thinks that if I up the font size on a site, I want all pages in that tab rather than on that site to be big.

posted at 09:35 -07:00 | os10 | two comments

February 16, 2005


spooky$ ioreg -lw0 | grep Capacity | head -1 | \
perl -F',' -lane 's/.*{|}.*//,print for @F'
"Cycle Count"=590

No wonder my battery doesn’t last very long. Time to start saving for a new one.

posted at 17:17 -07:00 | os10 | eight comments

February 12, 2005


Virtue is another virtual desktop system for OS X. It’s based on Desktop Manager, and works mostly the same. The biggest new feature is automatic switching to the desktop of the focused application… very nice.

posted at 16:21 -07:00 | os10 | no comments

address book with google maps

Apple’s Address Book comes with a context menu item to open an address in Mapquest. I found a script today for using Google Maps instead. Copy Google Map of.scpt to ~/Library/Address Book Plug-Ins.

464 elliott st

posted at 16:13 -07:00 | os10 | no comments

November 19, 2004


New hard drive! Hooraj! And the first re-install of OS X in a long, long time.

I backed up most of my home directory but decided to re-install my applications. Why? I don’t know.

Essential applications: * Quicksilver: my computer felt broken without this. * uControl: Caps Lock to Control, Enter (to the right of my space bar) to Command, scrollwheel emulation with Function + touchpad. The uControl installer checks for specific versions of IOHIDFamily. OS X 10.3.6 has version 1.3.5, newer than uControl 1.4.4). Adding it to uControl1.4.4.pkg/Contents/Resources/InstallationCheck fixes the installer. * Desktop Manager: virtual desktops for OS X. * BitTorrent * SSHKeychain * MPlayerOSX * Shrook: for RSS and Atom feeds. * Growl: Little notification bubbles that show stuff like the current song in iTunes. * MenuCalendarClock: the new version of CalendarClock. There’s a pay version now, but the free version still does everything I want. And now Sundays aren’t red.

posted at 21:59 -07:00 | os10 | four comments

September 17, 2004


Saft is a plugin for Safari that adds a lot of features. The most important to me were

  1. Mozilla-style type-ahead find.
  2. Force links to open in a tab. No new windows! This didn’t work quite as I’d like. It would be better if links always opened in the current tab unless you command-click on them.
  3. Remember open tabs when quitting Safari. I’m not sure if it works with crashes as well. That would be ideal.

Saft is unfortunately nagware. A dialog box appears when Safari starts and then periodically after that. The period seemed to be about five minutes. It was so annoying I deleted it within an hour, despite loving the features. Maybe this will motivate me to learn how to write my own InputManager.

More satisfying is I-Search Plugin, which adds Emacs-style (C-s, C-r) incremental searching to any NSTextView (i.e., most os10 apps).

posted at 19:57 -07:00 | os10 | no comments

August 03, 2004


Calendarclock lets you have the date as well as the time on your menu bar. You can choose from a list of presets or make your own with strftime(3) formats.

Clicking on the clock makes a little calendar drop down.


It includes iCal events, which is great since I rarely remember to check iCal.

posted at 12:19 -07:00 | os10 | no comments

July 21, 2004

virtual desktops

When I switched to OS X, it took me a long time to get used to not having virtual desktops. Eventually having a big pile of windows seemed normal. I used Cmd-Tab, the Dock, and Exposé, and it worked well enough.

As soon as I installed Desktop Manager I was sold on it. There are some glitches—mostly related to off-screen windows having the focus—but nothing that seriously gets in the way. It’s GPL’d, too, which is a treat in the Mac culture of shareware everything.

My menu bar is getting crowded. menu bar

posted at 23:10 -07:00 | os10 | two comments

no quit

I just hit Cmd-Q by accident in Safari again. With a lot of tabs open.

defaults write NSUserKeyEquivalents -dict-add "Quit Safari" "nil"

Even better would be if Safari remembered the pages you had open when it quit or (especially) crashed. Galeon did that for me years ago.

posted at 22:43 -07:00 | os10 | no comments

July 13, 2004

remove safari's pop-up blocking shortcut

It’s great that Safari (and every other sane web browser) blocks pop-ups. It’s not so great that Command-K toggles the blocking. I’ve turned it off by accident a number of times, probably when trying to use Command-K in the Finder, where it means “Connect to Server”.

About a month ago I found a hint on how to remove the shortcut:

defaults write NSUserKeyEquivalents -dict-add "Block Pop-Up Windows" "nil"


posted at 11:13 -07:00 | os10 | no comments

March 31, 2004


quicksilver command window

I’ve been addicted to LaunchBar for a while now. Quicksilver is the same idea: you hit command-space and then type part of the name of whatever you want to open/find/whatever. So, command-space-t-enter gets me a terminal.

Quicksilver looks nicer than LaunchBar, and with the bevel mode (see image above) it pops up right in the centre of the screen. That makes sense to me, since it’s busy capturing my keystrokes.

Web searches are easy. Bookmarks with quicksilver (instead of the usual %s) in the url (like will pop up a search dialog, which then opens a new tab in Safari with the result.

Support for browsing iPhoto, iTunes, and Address Book is built in.

It’s still beta for sure, though; it’s crashed twice already.

posted at 00:03 -07:00 | os10 | no comments

March 29, 2004


If you’ve used Unix much you’ll have noticed that programs really don’t agree on the whole backspace and delete thing. Back when I had Debian on my laptop, it generally worked how I expected. OS X’s Terminal isn’t quite so smooth. I decided to finally sort it all out.

If this saves anyone some effort, great. If not, why did I spend all this time writing an unclear explanation of a stupid problem?

what I wanted

  • backspace (“delete” on my keyboard) to mean “delete the character before the cursor”
  • delete (“fn-delete”) to mean “delete the character after the cursor” (not such a big deal since I never use it)
  • have it work everywhere: bash, vi, emacs, mutt, and curses-based programs (like pkr)
  • have it work locally (OS X) and remotely (Debian and Solaris)
  • minimal changes to configuration files

make it work

I’m using, with $TERM set to xterm-color (in Preferences). “Use option keys as meta key” is checked in Window Settings. That isn’t directly related, but it makes using Emacs a lot nicer. By default, backspace (“delete”) sends ^? and delete (“forward delete”, “fn-delete”) sends ^[[3~ (escape, open square bracket, three, tilde). You can see what your terminal is producing with this C program:
void main(void) {int c; while(c = getchar()) printf("%d 0x%02X\n", c, c);}
Run stty erase undef first.

stty has erase = ^?, the default. That’s ASCII DEL (127 or \177), and it should (ha!) work as backspace everywhere. The terminfo entry for xterm-color (and all the other terminals that emulates) reports the kbs (backspace) capability as ^H. To match it should be \177. I could go the other way and use stty erase ^H, but then C-h wouldn’t run help-command in Emacs unless I fucked around with .emacs. Probably curses-based programs (which actually use terminfo, as far as I can tell) will not work properly, but I don’t use any locally. Bash, Emacs, and Vim all do their own thing.

On okcomputer (Debian), I again have erase = ^? in stty. infocmp reports kbs=^H and kdch1=\177. No good. Setting TERM=xterm-debian fixes that. Now kbs=\177 and kdch1=^[[3~, which is what is emitting. The only problem is that $TERM gets passed on if you connect to other systems, and no other system knows what the fuck xterm-debian is. I might end up making my own xterm terminfo entry. Sigh.


posted at 02:06 -07:00 | os10 | three comments

March 23, 2004

iphoto 4.0.1

Software Update had an iPhoto upgrade for me, so I installed it. After that, the iPhoto icon changed to a generic application icon, and launching iPhoto from the dock gave three bounces and then nothing (don’t you love Mac bug reports?).

Disk Utility’s Repair File Permissions fixed the problem, and now iPhoto is happily “upgrading thumbnails”. Why were my permissions wrong in the first place?

posted at 10:52 -07:00 | os10 | no comments

November 13, 2003


I haven't actually used Clutter for its main purpose (making little windows of all your album covers), but it works nicely as a smaller interface to iTunes. Not as small as the mini iTunes window, but it includes album art it grabs from Amazon.

The best part is the album-oriented browser. It puts compilations under “Compilations” in the artist section, rather than spewing them all over the place like iTunes and the iPod do.
clutter browser

posted at 12:45 -07:00 | os10 | seven comments

pdf manpages

If you're feeling all graphical, preman is a script to open manpages in Preview. Based on a hint from macosxhints.

posted at 10:21 -07:00 | os10 | no comments