

# grep -E "^setenv" /etc/nf | xargs -t -L 1 launchctl # NOTE: You will still need to restart the relevant application (including # environment variables globally without needing to reboot. # After editing this file run the following command from the terminal to update # (and Terminal), including those launched via Spotlight. Put contents like the following into the file # Set environment variables here so they are available globally to all apps Type sudo vi /etc/nf (note: this file might not yet exist) Please note that ist does not work for applications launched via Spotlight.

I've done extensive research and if you want to set variables that are available in all GUI applications, your only option is /etc/nf. You can find out more about launchctl and how it loads nf with the command man launchctl.īruno is right on track. If you want these changes to take effect now, you should use this command to reprocess nf (thanks for the tip!) egrep -v '^\s*#' /etc/nf | launchctl
.jpg)
nf is executed automatically when you reboot. To keep changes after a reboot you can set the environment variables from /etc/nf, like so: setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin The launchctl man page quote at the top of this answer says the feature described here (reading /etc/nf at boot) was removed for security reasons, so ymmv. Use launchctl config user path /bin:/usr/bin:/mystuff. How to keeping changes after a reboot New method (since 10.10 Yosemite) with export PATH=/opt/local/bin:/opt/local/sbin:$PATH for bash or zsh. This includes any shells already running under Terminal.app, although if you're there you can set the environment more directly, e.g. There's no need to reboot though you will need to restart an app if you want it to pick up the changed environment. bashrc or similar, then have it mirrored in launchd: PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin For example to set the path: launchctl setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin You can set the environment used by launchd (and, by extension, anything started from Spotlight) with launchctl setenv. How to set the environment for new processes started by Spotlight (without needing to reboot) While it was documented that $HOME/.nf would be consulted prior to setting up a user's session, this functionality was never implemented. The /etc/nf file is no longer consulted for subcommands to run during early boot time this functionality was removed for security considerations. Launchctl no longer has an interactive mode, nor does it accept commands from stdin. The man page for launchctl says that it never worked:
