Created
October 24, 2013 13:11
-
-
Save tbuckel/7137034 to your computer and use it in GitHub Desktop.
Revisions
-
tbuckel revised this gist
Oct 24, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ From http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/3756686 Setting the environment for new processes started by Spotlight You can set the environment used by launchd (and, by extension, anything started from Spotlight) with launchctl setenv. For example to set the path: -
tbuckel created this gist
Oct 24, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ Setting the environment for new processes started by Spotlight You can set the environment used by launchd (and, by extension, anything started from Spotlight) with launchctl setenv. For example to set the path: launchctl setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin Or if you want to set up your path in .bashrc or similar, then have it mirrored in launchd: PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin launchctl setenv PATH $PATH There's no need to reboot though you will need to restart an app if you want it to pick up the changed environment. This includes any shells already running under Terminal.app, although if you're there you can set the environment more directly, e.g. with export PATH=/opt/local/bin:/opt/local/sbin:$PATH for bash or zsh. Changes will be lost after a reboot To keep changes after a reboot you can set the environment variables from /etc/launchd.conf, like so: setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin launchd.conf is executed automatically when you reboot. If you want these changes to take effect now, you should use this command to reprocess launchctl.conf (thanks @mklement for the tip!) egrep -v '^\s*#' /etc/launchd.conf | launchctl You can find out more about launchctl and how it loads launchd.conf with the command man launchctl.