分页: 1 / 1

Terminal 不加载 ~/.profile

发表于 : 2011-11-10 16:00
colder
什么情况?

我在 ~/.profile 末尾加入 npm 激活脚本.

if [ -f "$HOME/.nvm/nvm.sh" ]; then
. "$HOME/.nvm/nvm.sh"
fi

结果发现 Terminal 好像并没有要读取 ~/.profile 的样子.

Re: Terminal 不加载 ~/.profile

发表于 : 2011-11-10 16:04
eexpress
某些配置会废弃的。换个地方嘛。

Re: Terminal 不加载 ~/.profile

发表于 : 2011-11-10 16:07
lilydjwg
login shell 才加载那个。

Re: Terminal 不加载 ~/.profile

发表于 : 2011-11-10 16:33
colder
eexpress 写了:某些配置会废弃的。换个地方嘛。
那我该放在哪里才好呢?
之前有玩OSX, 现在刚到Ubuntu下, 有点迷糊.
这个Terminal是什么? 不是bash吗?

Re: Terminal 不加载 ~/.profile

发表于 : 2011-11-10 16:34
leeaman
放.bashrc没错吧?

Re: Terminal 不加载 ~/.profile

发表于 : 2011-11-10 17:25
colder
leeaman 写了:放.bashrc没错吧?
谢谢, 果然是这样, 可是还是有点迷糊.

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.

问题是我的用户目录下没有 .bash_profile 和 .bash_login.
只有 .bash_history 和 .bash_logout

Re: Terminal 不加载 ~/.profile

发表于 : 2011-11-10 19:55
naturalaw
你可以創建啊.
if ~/.bash_profile or ~/.bash_login
如果有,就不讀取了~/.profile

Re: Terminal 不加载 ~/.profile

发表于 : 2011-11-11 8:46
colder
看来每种发行版, bash 配置文件的加载也是不同的.


对于Ubuntu 11.10来说, 加载顺序应该是:
/etc/profile
/etc/profile.d/*.sh
/etc/bash.bashrc
~/etc/.profile (登录时加载一次)
~/etc/.bashrc (每次打开Terminal时加载)

但是系统的预安装配置里把~/.bash_profile给丢掉了.


在OSX里又是另外一回事, 每次打开Terminal都加载~/.profile, 其他的都被忽略了.