Three ways to launch a program automatically when Mac OS X starts up: Login items, Startup items and launchd daemons (nicely summarized here).
Login items is very convenient but seems to be only for GUI program. For shell script, it will run but leaves user a visible default editor with script in it! By creating a .plist file and putting it in user's own
~/Library/LaunchAgents directory instead of system-wide
/Library/LaunchDaemons, problem solved. This post helped.