【发布时间】:2010-10-12 10:42:06
【问题描述】:
当我登录到 sun box 时:SunOS domain.com 5.8 Generic_117350-57 sun4u sparc SUNW,Sun-Fire-V240
我从 sh shell 开始:SHELL=/bin/sh
我输入 bash 来启动一个 bash shell,然后必须输入 . .bash_profile 加载我的个人资料。有没有办法可以设置为自动加载配置文件?
【问题讨论】:
当我登录到 sun box 时:SunOS domain.com 5.8 Generic_117350-57 sun4u sparc SUNW,Sun-Fire-V240
我从 sh shell 开始:SHELL=/bin/sh
我输入 bash 来启动一个 bash shell,然后必须输入 . .bash_profile 加载我的个人资料。有没有办法可以设置为自动加载配置文件?
【问题讨论】:
文件.bash_profile 在登录时运行。当从非登录会话运行 bash 时,将运行文件 .bashrc。
尝试将此添加到您的.bashrc:
source ~/.bash_profile
【讨论】:
像这样运行 bash 会导致它获取源 /etc/bash.bashrc 然后 ~/.bashrc 代替 .bash_profile (和其他文件)。因此,将. ~/.bash_profile 放入~/.bashrc 中,(或放入/etc/bash.bashrc 中以对所有用户执行此操作)。
【讨论】:
.bash_profile 仅用于登录 shell,对于非登录 shell(如您的),bash 使用 .bashrc。
最简单的方法是将. .bash_profile 添加到您的.bashrc。
您还必须确保不在非交互式 shell 中打印出任何内容,否则您可能会破坏 scp/sftp。
【讨论】:
放
。 ~/.bash_profile
在 ~/.bashrc 中(注意无限循环!)。我自己不使用它,因为我在 .bashrc 中开始使用大多数东西(除了,嗯,环境。东西等等)。
【讨论】: