.bashrc not reload from script
Iam newbee in bash scripts . I am trying to add a line on .bashrc file :
## make python 2.7 default in ~/.bashrc
echo 'export PATH=/usr/local/lib/python/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
The source command is not reloading the ~/.bashrc file . (but works if i do it on the prompt )
How I can reload the .bashrc from the script ? any help will be more then appreciated .
Cheers
Aha! Modern *nix systems usually have a system-wide bashrc
that starts thus:
# 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
If you observe the last couple of lines the issue would become obvious. You are not running interactively. Before sourcing bashrc
in your script, set PS1
to an arbitrary value, say:
PS1='foobar'
and chances are that your bashrc
would suddenly start loading from the script!
上一篇: 如何用wget指定位置?
下一篇: .bashrc不能从脚本重新加载