Skip to content

Instantly share code, notes, and snippets.

@samtsai
Created March 26, 2014 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samtsai/9788989 to your computer and use it in GitHub Desktop.
Save samtsai/9788989 to your computer and use it in GitHub Desktop.
Setup launch agents (useful for automating brew installs and their startup script)
# Set Up Launch Agent to Run On Startup
function set_launch_agent() {
# retrieve the dependency's prefix
DEP_PREFIX=$(brew --prefix ${1})
# make the user local LaunchAgents directory (skip if already exists)
mkdir -p ~/Library/LaunchAgents
# copy brew generated plist to LaunchAgent
cp $DEP_PREFIX/*${1}*.plist ~/Library/LaunchAgents/
# load the agent now
launchctl load -w ~/Library/LaunchAgents/*${1}*.plist
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment