Terminal 不加载 ~/.profile

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
colder
帖子: 4
注册时间: 2008-11-08 10:40

Terminal 不加载 ~/.profile

#1

帖子 colder » 2011-11-10 16:00

什么情况?

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

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

结果发现 Terminal 好像并没有要读取 ~/.profile 的样子.
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: Terminal 不加载 ~/.profile

#2

帖子 eexpress » 2011-11-10 16:04

某些配置会废弃的。换个地方嘛。
● 鸣学
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: Terminal 不加载 ~/.profile

#3

帖子 lilydjwg » 2011-11-10 16:07

login shell 才加载那个。
头像
colder
帖子: 4
注册时间: 2008-11-08 10:40

Re: Terminal 不加载 ~/.profile

#4

帖子 colder » 2011-11-10 16:33

eexpress 写了:某些配置会废弃的。换个地方嘛。
那我该放在哪里才好呢?
之前有玩OSX, 现在刚到Ubuntu下, 有点迷糊.
这个Terminal是什么? 不是bash吗?
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: Terminal 不加载 ~/.profile

#5

帖子 leeaman » 2011-11-10 16:34

放.bashrc没错吧?
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
头像
colder
帖子: 4
注册时间: 2008-11-08 10:40

Re: Terminal 不加载 ~/.profile

#6

帖子 colder » 2011-11-10 17:25

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
头像
naturalaw
帖子: 1360
注册时间: 2011-09-06 22:04

Re: Terminal 不加载 ~/.profile

#7

帖子 naturalaw » 2011-11-10 19:55

你可以創建啊.
if ~/.bash_profile or ~/.bash_login
如果有,就不讀取了~/.profile
  • The eternal law
头像
colder
帖子: 4
注册时间: 2008-11-08 10:40

Re: Terminal 不加载 ~/.profile

#8

帖子 colder » 2011-11-11 8:46

看来每种发行版, bash 配置文件的加载也是不同的.


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

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


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