赞
踩
方法1:在~/.bash_profile中配置
vim ~/.bash_profile
方法2:在~/.bashrc中配置
vim ~/.bashrc
打开后,增加你需要的环境变量,例如:
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
之后,运行以下命令即可。
source ~/.bash_profile
或
source ~/.bashrc
重启终端,可能会遇到配置好的环境变量失效的情况。发现zsh加载的是 ~/.zshrc,而 ‘~/.zshrc’ 文件中并没有定义刚才的环境变量。
解决办法:
打开~/.zshrc文件,在最后增加一行:
source ~/.bash_profile
或
source ~/.bashrc
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。