.bashrc不能从脚本重新加载
Iam newbee在bash脚本中。 我试图在.bashrc文件中添加一行:
## make python 2.7 default in ~/.bashrc
echo 'export PATH=/usr/local/lib/python/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
源命令不重装〜/ .bashrc文件。 (但是,如果我在提示上这样做的话)
我如何从脚本重新加载.bashrc? 任何帮助将更多,然后赞赏。
干杯
啊哈! Modern * 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
可能你的bashrc
会突然从脚本开始加载!
上一篇: .bashrc not reload from script
下一篇: .bashrc at ssh login