add a start up item via command line (mac)

nightfire picture nightfire · Apr 2, 2010 · Viewed 18.4k times · Source

How can I add a start up item via command line on a mac? From googling, I know you have to edit ~/Library/Preferences/com.apple.loginitems.plist using defaults write com.apple.loginitems [key] [value] but i'm not sure exactly which things to edit.

Answer

Michael Aaron Safyan picture Michael Aaron Safyan · Apr 2, 2010

On Mac OS X 10.6 Snow Leopard, it is even simpler than that:

sudo launchctl submit -l name_of_startup_item -- command [args]

See man launchctl. On earlier versions, it is recommended that you create a Launch Daemon PLIST file and load/start it with launchctl rather than create a startup item... the startup items are the old school way.