lunchy: A friendly wrapper for OS X launchctl

Wynn Netherland Wynn Netherland

If you run OS X, you’ve probably encountered some frustration with Apple’s launchctl command line options when starting, stopping, and restarting your launchd daemons. Whereas most things Apple are minimalist, launchctl options are quite verbose. For example, how many times have you installed a Homebrew package only to get met with something like:

If this is your first install, automatically load on login with:
    cp /usr/local/Cellar/mongodb/1.6.5-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
    cp /usr/local/Cellar/mongodb/1.6.5-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Or start it manually:
    mongod run --config /usr/local/Cellar/mongodb/1.6.5-x86_64/mongod.conf

So to crank up Mongo you want me to pass that entire path to launchctl?

Lunchy - “Start your agents and go to lunch”

Thank goodness there’s Lunchy from Mike Perham. Lunchy simplifies the command line interface to launchctl. To get started, install the gem:

gem install lunchy

Now we can list all of our agents with ls

» lunchy ls

… and start MongoDB with

lunchy start mongo

To see the full range of options, just type lunchy with no arguments:

Supported commands:

 ls [pattern]       Show the list of installed agents, with optional [pattern] filter
 start [pattern]    Start the first agent matching [pattern]
 stop [pattern]     Stop the first agent matching [pattern]
 restart [pattern]  Stop and start the first agent matching [pattern]
 status [pattern]   Show the PID and label for all agents, with optional [pattern] filter

Got an idea to improve upon Lunchy? Go ahead and fork the project

[Source on GitHub]

0:00 / 0:00