ubuntu中 .bashrc 没有被执行(.bashrc not executed when opening new terminal)
.bashrc 没有被执行
当我在Ubuntu 12.04中打开新的终端窗口时,.bashrc中的代码不执行。 创建.bash_aliases文件时,我注意到了这一点。 当我打开一个新终端时,别名没有显示。 但是,当我输入source .bashrc时,别名确实出现了。
.bashrc应该在每次打开新的终端窗口时运行,对吗?
我如何做到这一点?
如何解决
它不一定运行; 在标准.bashrc
的顶部是此注释:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
我相信可以选择是否将bash终端作为登录shell运行。 在Ubuntu中,gnome-terminal通常不作为登录shell运行,因此.bashrc
应该直接运行。
对于登录外壳程序(如虚拟终端),通常运行〜/.profile文件,除非您具有〜/.bash_profile或〜/.bash_login,但默认情况下不存在。 默认情况下,Ubuntu仅使用.profile
。
标准〜/ .profile中包含以下内容:
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
如果可用,它将运行.bashrc-假定环境中存在$ BASH_VERSION。 您可以通过输入命令echo $ BASH_VERSION进行检查,它应该显示一些有关版本号的信息-不能为空。
原文: [.bashrc not executed when opening new terminal] https://askubuntu.com/questions/161249/bashrc-not-executed-when-opening-new-terminal
还没有评论,来说两句吧...