2013-08-16 125 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突然從劇本開始裝載