2013-08-16 71 views
2

IAM newbee在bash脚本中。 我想补充的.bashrc文件的行:.bashrc不能从脚本重新加载

## make python 2.7 default in ~/.bashrc 
echo 'export PATH=/usr/local/lib/python/bin:$PATH' >> ~/.bashrc 
source ~/.bashrc 

源命令不重装〜/ .bashrc文件。 (但作品,如果我这样做的提示)

我怎么能从脚本重新加载.bashrc? 任何帮助将更多然后赞赏。

干杯

回答

1

啊哈!现代* nix系统通常有一个全系统的bashrc启动这样的:

# System-wide .bashrc file for interactive bash(1) shells. 

# To enable the settings/commands in this file for login shells as well, 
# this file has to be sourced in /etc/profile. 

# If not running interactively, don't do anything 
[ -z "$PS1" ] && return 
... 
stuff follows 

如果你观察的最后几行的问题将变得明显。你是而不是交互式运行。在你的脚本采购bashrc之前,设置PS1为任意值,说:

PS1='foobar' 

,并有机会,你会bashrc突然从剧本开始装载