Zsh中是否有类似.bash_profile的内容? [英] Is there anything in Zsh like .bash_profile?

查看:44
本文介绍了Zsh中是否有类似.bash_profile的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次打开终端时,我都必须获取 .bash_profile 的源代码以启用 $ JAVA_HOME 或其他变量.

Everytime I open the terminal, I have to source .bash_profile to enable the $JAVA_HOME or other variables.

推荐答案

是的,它称为〜/.zshenv .

这是我在〜/.zshenv 中设置 $ JAVA_HOME 的方式:

Here's how I have $JAVA_HOME set in ~/.zshenv:

export JAVA_HOME="$(/usr/libexec/java_home)"

但是请记住,zsh是不是 bash,所以只是因为您每次打开终端时都必须获取 .bash_profile ,所以不是,这意味着您必须使用zsh来执​​行此操作.使用zsh时,我只需要重新修改〜/.zshenv 的资源,然后仅对于已经打开的终端 em>:新终端应该已经采购了我的新的和改进的〜/.zshenv .

Keep in mind, however, that zsh is not bash, so just 'cause you have to source your .bash_profile every time you open a terminal does not mean that you have to do that with zsh. With zsh, I only have to re-source my ~/.zshenv when I make changes to it, and then only for terminals which are already open: new terminals should have already sourced my new and improved ~/.zshenv.

注意

当我尝试确定应该将哪些zsh启动文件放入文件中以进行咨询时,我经常会发现它很有帮助.

I often find it helpful, when trying to determine which of my zsh startup files I should place things in to consult zsh startup files.

这篇关于Zsh中是否有类似.bash_profile的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆