热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何修复终端不加载~/。bashrc在OSXLion上。-HowtofixTerminalnotloading~/.bashrconOSXLion

WheneverIopenanewtabinTerminalusingCmd+T,itopensbashinthesamedirectory,asthepre

Whenever I open a new tab in Terminal using Cmd + T, it opens bash in the same directory, as the previous tab. This works fine when I'm in the ~ directory, but if I'm anywhere else, I get an error loading .bashrc

每当我在终端使用Cmd + T打开一个新标签时,它会在同一个目录中打开bash,就像前面的标签一样。当我在~目录下时,这很正常,但是如果我在其他地方,我就会得到一个错误加载。bashrc。

Last login: Sat Oct 15 21:10:00 on ttys002
-bash: .bashrc: No such file or directory
Jakub-Arnolds-MacBook-Pro:projects darth$ 

It looks like .bashrc is loaded via relative and not absolute path, because if I do source ~/.bashrc, everything works smoothly.

它看起来像。bashrc是通过相对而不是绝对路径加载的,因为如果我做source ~/。bashrc,(一切工作顺利。

loaded bashrc

I think this is a OS X Lion related problem, because before the upgrade from Snow Leopard, I didn't have the same issue. But that might be caused by Terminal always opening at ~, I don't remember if it tried to open the same directory.

我认为这是一个OS X Lion相关的问题,因为在雪豹升级之前,我没有遇到同样的问题。但这可能是由于终端总是在~上打开,我不记得是否尝试打开相同的目录。

However the question remains the same, how can I make Terminal load ~/.bashrc via absolute path, and not relative?

但是问题仍然是一样的,我怎么能做终端负载~/。bashrc是通过绝对路径,而不是相对的?

3 个解决方案

#1


313  

Terminal opens a login shell. This means, ~/.bash_profile will get executed, ~/.bashrc not.

终端打开一个登录shell。这意味着,~ /。bash_profile将被执行,~/。bashrc。(

The solution on most systems is to "require" the ~/.bashrc in the ~/.bash_profile: just put this snippet in your ~/.bash_profile:

大多数系统的解决方案是“要求”~/。bashrc中(~ /。bash_profile:将这段代码放到~/.bash_profile中:

[[ -s ~/.bashrc ]] && source ~/.bashrc

#2


24  

Renaming .bashrc to .profile (or soft-linking the latter to the former) should also do the trick. See here.

重命名.bashrc to .profile(或将后者软链接到前者)也应该做到这一点。在这里看到的。

#3


11  

I have the following in my ~/.bash_profile:

我在~/.bash_profile中有以下内容:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

If I had .bashrc instead of ~/.bashrc, I'd be seeing the same symptom you're seeing.

如果我有。bashrc而不是~/。bashrc,我看到的症状和你看到的一样。


推荐阅读
author-avatar
他们叫我红豆
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有