Bash .profile 未加载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/11498070/
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
Bash .profile not loading
提问by Peter
I'm not sure what's happened but my ~/.profile is no longer loading.
我不确定发生了什么,但我的 ~/.profile 不再加载。
Can anyone see something wrong with the following?
任何人都可以看出以下内容有问题吗?
export PS1="\u@local [\w]# "
export EDITOR="subl -w"
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
alias vst="ssh -i ~/.ssh/vst root@vst"
I know for a fact using that PS1 like I am attempting to do it should be doing Peter@local [~/path/to/file]#but it's not.
我知道使用 PS1 就像我试图这样做的事实应该这样做,Peter@local [~/path/to/file]#但事实并非如此。
Any ideas?
有任何想法吗?
回答by Gordon Davisson
Does ~/.bash_profileor ~/.bash_loginexist?  If so, that'll be used instead of ~/.profile.
是否~/.bash_profile还是~/.bash_login存在吗?如果是这样,将使用它而不是~/.profile.
回答by kenorb
In Unix FAQ (for OS X)we can read:
在Unix FAQ(对于 OS X)中,我们可以阅读:
Bash Startup Files
When a "login shell" starts up, it reads the file
/etc/profileand then~/.bash_profileor~/.bash_loginor~/.profile(whichever one exists - it only reads ONE of these, checking for them in the order mentioned).When a "non-login shell" starts up, it reads the file
/etc/bashrcand then the file~/.bashrc.Note that when bash is invoked with the name
sh, it tries to mimic the startup sequence of the Bourne shell (sh). In particular, a non-login shell invoked asshdoes not read any dot files by default. See the bash man page for details.
Bash 启动文件
当“登录外壳”启动时,它会读取文件
/etc/profile,然后~/.bash_profile或~/.bash_login或~/.profile(无论哪个存在 - 它只读取其中一个,并按照提到的顺序检查它们)。当“非登录 shell”启动时,它会读取文件
/etc/bashrc,然后读取文件~/.bashrc.请注意,当使用名称 调用 bash 时
sh,它会尝试模仿 Bourne shell (sh)的启动顺序。特别是,默认情况下调用 as 的非登录 shellsh不读取任何点文件。有关详细信息,请参阅 bash 手册页。
So if you already have ~/.bash_profile, the file ~/.profilewon't be automatically read by bash, therefore you can add the following lines in your ~/.bash_profileto load it:
因此,如果您已经有了~/.bash_profile,该文件~/.profile将不会被 bash 自动读取,因此您可以在您的文件中添加以下几行~/.bash_profile来加载它:
# Load user profile file
if [ -f ~/.profile ]; then
  . ~/.profile
fi

