如何解决终端不能在OS

如何解决终端不能在OS

本文介绍了如何解决终端不能在OS X Lion中加载的〜/ .bashrc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我使用打开终端的新标签 Cmd的 + T ,它会打开在同一目录下的bash,为previous标签。当我在目录是这个工作正常,但如果我在其他地方,我得到一个错误加载的.bashrc

Whenever I open a new tab in Terminal using + , 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

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

看起来的.bashrc 通过相对的而不是绝对路径加载,因为如果我这样做源的〜/ .bashrc ,一切工程进展顺利。

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

我觉得这是一个OS X Lion的相关的问题,因为从雪豹升级之前,我没有足够的同样的问题。但是,这可能是由终端总是在打开,我不记得,如果它试图打开同一个目录引起的。

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.

然而,问题仍然是一样的,我怎样才能使终端负载〜/ .bashrc中通过绝对路径,而不是相对的?

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

推荐答案

终端打开一个登录shell。这意味着,〜/ .bash_profile中将得到执行,〜/ .bashrc中不是

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

在大多数系统的解决方案是规定的〜/ .bashrc中〜/ .bash_profile中 :只是把这个片段在你的〜/ .bash_profile中

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

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

这篇关于如何解决终端不能在OS X Lion中加载的〜/ .bashrc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 11:35