One perk of working on a mac over other *nix variants is the tight integration with many of the higher-level os-specific features that make apple machines so nice to use. Here are a few you might not be aware of:

open

Pretty much does what it says on the tin. Pass it a file or directory. It’ll either open with the default application, or open up a finder window for the latter.

mdfind

Hit the spotlight index through the command line. I have an alias for “mdfind —onlyin . $1” for finding, say, a method in a big ruby project I don’t know very well. It’s a hell of a lot quicker than textmates’ command+shift+f search which freezes with alarming regularity.

say “something”

Text-to-speech tool. Pass it a string, and your wise words are reiterated. Use this while ssh’ed into a mac near you to convince the user they have Alzheimer’s. This is particularly effective when used in conjunction with “osascript -e ‘set volume 25’” to turn their speaker volume down beforehand. For even greater impact, run it as a cronjob.

osascript -e “script”

Inline evaluation of AppleScript. With Apple’s OSA you get a pretty expansive command set for controlling system behaviour, the finder, standard apps like iTunes. Try firing up the script editor utility and loading an application dictionary. I set the alias tmreload=”osascript -e ‘tell app “TextMate” to reload bundles’” to quickly reload textmate’s bundle list. For the rubyists, there’s an Apple-sponsored RubyOSA gem as well.

pbcopy

Pipe your output into pbcopy, then paste it into native Cocoa applications.

opendiff file1 file2

Fires up FileMerge, diffing the two files you passed as arguments.

dns-sd -R ‘share_name’ service_type . port extra_arguments”

Announce a service using mDNS. A list of service types is maintained here.

I’ve neglected to talk about things like launchd and the plethora of command-line tools adorned on OS X Server Administrators.

† I’m an OpenBSD purist; why complicate process management anyway?