Setting variables in environment.plist
-
Unload the launch agent:
launchctl unload ~/Library/LaunchAgents/environment.plist
- Modify the plist/env settings
-
Load the launch agent again:
launchctl load ~/Library/LaunchAgents/environment.plist
You have to quit and relaunch Terminal to get the new value of the variable in the shell.
With the example of Kuldeep Yadav's comment the usr.aws.plist in ~/Library/LaunchAgent/ would look like this then:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>usr.aws</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>AWS_SECRET_ACCESS_KEY</string>
<string>loremipsum</string>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>AWS_ACCESS_KEY_ID</string>
<string>loremipsum2</string>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>AWS_ACCESS_KEY</string>
<string>loremipsum3</string>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>AWS_SECRET_KEY</string>
<string>loremipsum4</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
This is only tested (& working) with bash & zsh.