bash 如何使 .bashrc 中的更改在当前终端中生效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16850817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to make changes in .bashrc effective in current terminal
提问by damon
I have an open terminal in ubuntu lucid in which I need a new env variable set.So,I open the .bashrc file and edit it ,to add the new env variable( say PYTHONPATH)
我在 ubuntu lucid 中有一个开放终端,我需要一个新的 env 变量集。所以,我打开 .bashrc 文件并编辑它,以添加新的 env 变量(比如 PYTHONPATH)
.bashrc
.bashrc
PYTHONPATH=/some/path
export PYTHONPATH
But,in order to get this effective ,I need to close my terminal and open it again.Is there some command with which I can get this effect,without close/open the terminal again.
但是,为了使其有效,我需要关闭我的终端并再次打开它。是否有一些命令可以使我获得这种效果,而无需再次关闭/打开终端。
回答by arkascha
Take a look at the sourcecommand: man source
看一下source命令:man source
source ~/.bashrc
Apart from that: why don't you simply use the environment commands directly in your shell to set an additional environment variable?
除此之外:为什么不直接在 shell 中使用环境命令来设置额外的环境变量?
export PYTHONPATH="/some/path"
That way the created variable is effective right away.
这样创建的变量立即生效。
回答by sat
You can also try,
你也可以试试,
sat:~# . ~/.bashrc

