Environment variables in Mac OS X

后端 未结 9 1528
萌比男神i
萌比男神i 2020-11-22 14:57

Update: The link below does not have a complete answer. Having to set the path or variable in two places (one for GUI and one for shell) is lame.

No

9条回答
  •  死守一世寂寞
    2020-11-22 15:07

    There's no need for duplication. You can set environment variables used by launchd (and child processes, i.e. anything you start from Spotlight) using launchctl setenv.

    For example, if you want to mirror your current path in launchd after setting it up in .bashrc or wherever:

    PATH=whatever:you:want
    launchctl setenv PATH $PATH
    

    Environment variables are not automatically updated in running applications. You will need to relaunch applications to get the updated environment variables (although you can just set variables in your shell, e.g. PATH=whatever:you:want; there's no need to relaunch the terminal).

提交回复
热议问题