为每个终端加载.bash_profile [英] Load .bash_profile for every terminal
问题描述
我在Max OS X的 .bash_profile 中设置了一些别名. 它可以工作,但是当我打开一个新标签时,我总是必须使用以下命令加载我的 .bash_profile 文件:
I set up some aliases in my .bash_profile on my Max OS X. It works but when I'm opening a new tab I always have to load my .bash_profile file with this command:
source ~/.bash_profile
即使我重新启动Mac或Linux计算机,如何使它在我打开的每个终端上都能正常工作?
How can I make it work for every terminal I'm opening, even if I'm restarting my Mac or Linux computer?
推荐答案
对于交互式非登录shell,开始时执行的文件可能是几个,通常是〜/.bashrc.我认为您正在使用的那种.
The files executed at the start may be several, usually ~/.bashrc for interactive, non-login shells. The kind I assume you are using.
如果是,则创建一个~/.bashrc
文件并在其中创建源~/.bash_profile
:
If so, create an ~/.bashrc
file and source ~/.bash_profile
in it:
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
研究此图片,因为它是精简指南
Study this image, as it is a condensed guide
If you do need to find out exactly which file is being executed, take a look at this web page. It has a lot of specific tests to find out what file is setting what.
特定于Mac-OS(这是一个例外,它会加载〜/.bash_profile),其操作与此链接的站点答案.在确认您的bash是否按照此处的说明进行操作之后.
Specific for Mac-OS (which is an exception and loads ~/.bash_profile) do as is recomended in the site linked in this answer AFTER you confirm that your bash is doing as explained there.
这篇关于为每个终端加载.bash_profile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!