0

I use the environment.plist method to setup global variables in macOS. I have this template in ~/Library/LaunchAgents

<?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>setenv.XDG</string>
        <key>Program</key>
        <string>/bin/zsh</string>
        <key>ProgramArguments</key>
        <array>
            <string>/bin/zsh</string>
            <string>-c</string>
            <string>
                launchctl setenv FOO BAR;
            </string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
</plist>

It works.

But: when I restart my computer, I need to open Terminal.app and close it at least once or the variables will not be available to GUI apps.

How shall I change that setup to skip opening Terminal.app after a reboot?

4
  • Does zsh not use set/ setenv command to set environment variables ? unix.stackexchange.com/questions/368944/…
    – anki
    Jun 29, 2020 at 7:28
  • Why did @nohillside remove my second question?
    – Damien L
    Jun 29, 2020 at 8:46
  • Sorry, forgot to add a comment. Please ask only one question per post, otherwise it's difficult to get good answers. You can always ask further questions in new posts.
    – nohillside
    Jun 29, 2020 at 9:10
  • @ankii this is about using launchctl to set global environment variables, the shell shouldn't matter.
    – nohillside
    Jun 29, 2020 at 9:11

0

You must log in to answer this question.

Browse other questions tagged .