2012-07-16 200 views
7

我不确定发生了什么,但我的〜/ .profile不再加载。Bash .profile not loading

任何人都可以看到以下错误吗?

export PS1="\[email protected] [\w]# " 
export EDITOR="subl -w" 
export CLICOLOR=1 
export LSCOLORS=GxFxCxDxBxegedabagaced 

alias vst="ssh -i ~/.ssh/vst [email protected]" 

我知道使用PS1像我试图去做应该做的事[email protected] [~/path/to/file]#一个事实,但它不是。

任何想法?

回答

17

请问~/.bash_profile~/.bash_login是否存在?如果是这样,那将用来代替~/.profile

+0

我其实并有一个'.bash_login'。从那里复制内容到.profile和删除bash_login修复它。谢谢。 – Peter 2012-07-16 06:40:55

+0

也为我工作。谢谢 – DaddyMoe 2015-08-05 12:39:19

+1

@Peter:kenorb给出的解决方案(http://stackoverflow.com/a/29152555/499797)比将所有信息粘贴到同一个文件中要好得多。 – javatarz 2015-09-18 07:13:39

-2

我必须登录到该用户才能获得~/.bash_profile~/profile重新加载更改。

su - drew 

您必须使用su和用户名之间的短划线。

+1

这看起来更像是评论,而不是回答。 – kenorb 2015-09-18 11:26:29

9

Unix FAQ (for OS X)我们可以看到:

巴什启动文件

当 “登录shell” 启动时,它读取文件 /etc/profile然后~/.bash_profile~/.bash_login~/.profile无论哪一个存在 - 它只读取其中的一个, 按照上述顺序检查它们)。

当“非登录shell”启动时,它会读取文件/etc/bashrc,然后读取文件~/.bashrc

请注意,当使用名称sh调用bash时,它会尝试模仿Bourne shell的启动顺序(sh)。特别是,被调用为sh的非登录shell在默认情况下不会读取任何点文件。有关详细信息,请参阅bash手册页。

所以,如果你已经~/.bash_profile,文件~/.profile将不会被自动读取bash的,所以你可以在你的~/.bash_profile添加以下行来加载它:

# Load user profile file 
if [ -f ~/.profile ]; then 
    . ~/.profile 
fi