Created
June 11, 2016 17:12
-
-
Save sgrankin/169914a5c6386aef6ca657b1af043d09 to your computer and use it in GitHub Desktop.
Docker machine LaunchAgent using launchctl to set environment vars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a shell archive. Save it in a file, remove anything before | |
# this line, and then unpack it by entering "sh file". Note, it may | |
# create directories; files and directories will be owned by you and | |
# have default permissions. | |
# | |
# This archive contains: | |
# | |
# Library/LaunchAgents/com.docker.machine.default.plist | |
# | |
echo x - Library/LaunchAgents/com.docker.machine.default.plist | |
sed 's/^X//' >Library/LaunchAgents/com.docker.machine.default.plist << 'END-of-Library/LaunchAgents/com.docker.machine.default.plist' | |
X<?xml version="1.0" encoding="UTF-8"?> | |
X<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
X<plist version="1.0"> | |
X<dict> | |
X <key>EnvironmentVariables</key> | |
X <dict> | |
X <key>PATH</key> | |
X <string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin</string> | |
X </dict> | |
X <key>Label</key> | |
X <string>com.docker.machine.default</string> | |
X <key>ProgramArguments</key> | |
X <array> | |
X <string>/bin/sh</string> | |
X <string>-c</string> | |
X <string>docker-machine start default && (docker-machine env --shell sh | awk 'BEGIN{FS="[ =]"} $1=="export"{system(sprintf("launchctl setenv \"%s\" \"%s\"", $2, $3))}')</string> | |
X </array> | |
X <key>RunAtLoad</key> | |
X <true/> | |
X</dict> | |
X</plist> | |
END-of-Library/LaunchAgents/com.docker.machine.default.plist | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment