Setting Environment Variables in Yosemite

What is the correct way to change environment variables such as PATH in Yosemite?

Here is this question Setting environment variables in OS X? but specifically for yosemite as it no longer works.

+4
source share
4 answers

Did you try to edit ~/.bash_profile?

Adding a line like this to bash_profileshould be done:

export PATH = / usr / local / bin: $ PATH

+3
source

Which shell are you using? I assume that you are using the standard Bash shell. There are also Csh, Ksh and Zsh.

Terminal.app Mac OS X . , $HOME/.bash_profile $HOME/profile , . . , PS1 set -o vi.

. , , xterm. . , , .bash_profile, .

$HOME/.bashrc , .

?

Kornshell (ksh), $HOME/profile, $HOME/.bash_profile. Zshell (zsh), . , . man- zsh ZDOTDIR.

script $HOME/.bashrc. - .bash_profile, .bashrc :

[[ -x $HOME/.bashrc ]] && source "$HOME/.bashrc"

, , script, export $PS4="\$LINENO> ".

$PATH . .bash_profile ( .bashrc), Mac OS X , . /etc/paths Bash Kornshell /usr/libexec/path_helper.

Mac $PATH :

/usr/local/bin:/usr/share/bin:/bin:/usr/bin:/usr/sbin:/sbin:$HOME/bin

, /opt, . ( - ) /usr/local/bin. , . , . , /usr/bin/git - 1.9.3. /usr/local/bin/git - 2.2.1.

, , /etc/profile, OS X.

+2

, /bin/ bash /bin/sh, envars, , ; , - Finder.

, - launchctl Mavericks, Apple . launchctl " " , . .

.

launchctll , . , ; .. setenv . . .profile .bashrc , launchctl.

, , startctl vars . Linux- .

Al .

+1

.

  • Click on “Terminal Menu” in the upper right corner.
  • click "Settings"
  • Click General
  • Change the shell using the command and put / bin / bash in the text box.

enter image description here

Now, any setting you make in ~ / .bash_profile takes effect. You didn’t use bash before (used ksh), so it didn’t read .bash_profile.

0
source

All Articles