Startup Scripts on OS X

I have a set number of programs that I usually want to start when my
macbook pro boots up. But sometimes I want to boot in a hurry and all
the startup items bother me. I came up with a solution I thought I’d
pass on.

I load Aquamacs automatically, as I use it for a terminal and several
other things. I wrote a ruby script that uses the applescript
libraries to ask If want to start the usual applications.

Then I call that script from Aquamacs as it loads. If I say no, then
only Aquamacs is loaded on boot. Otherwise, all the apps load.

First, install appscript…

#sudo gem install appscript

Then, put the following in a script file, I used ~/scripts/
load_programs.rb. Change the programs to match what you want.

#!/usr/bin/env ruby
require 'rubygems'
require 'appscript'
require 'osax'
include OSAX
include Appscript

start=[ "Firefox","Mail","iTunes","Microsoft Entourage"]
answer = osax.display_dialog("Do you want to launch #{start.join(',
:buttons =>
["Yes","No"], :default_button => "Yes")
if answer[:button_returned] == "Yes" then
start.each{|a| app(a).activate}

Then, at the bottom of your ~/.emacs file put:

(shell-command "ruby ~/scripts/load_programs.rb")

All the benefits of startup applications, only if you want them.