Yes, it's called ~/.zshenv
.
Here's how I have $JAVA_HOME
set in ~/.zshenv
:
export JAVA_HOME="$(/usr/libexec/java_home)"
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
.
NOTE
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.
A newer version of the documentation for startup files can be found here.
I know this is an old question, but I recently upgraded MacOs to Catalina which changed the default shell from bash to zsh.
I ended up doing this:
echo source ~/.bash_profile > ~/.zshenv && source ~/.zshenv
To have zsh source my original .bash_profile.
Other simple alternative to continue using your .bash_profile is add this file to your .zshrc file:
with this simple solution you can continue adding your .bash_prifile if you like zhs.
Adding .bash_profile
Recently, with the upgrade to macOS Catalina, the default shell changed to zsh, which uses ~/.zshrc
as the resource file.
We usually had ~/.bash_profile
inside user home directory the solution is to simply
~/.bash_profile
by running vim ~/.bash_profile
~/.zshrc
by running vim ~/.zshrc
~/.bash_profile
into ~/.zshrc
Open a new terminal window and run your previous aliases/scripts, which should work flawlessly.
In Mac Catalina onwards osx versions, the terminal uses zsh. There is a system-wide profile /etc/zprofile.
cat /etc/zprofile
# System-wide profile for interactive zsh(1) login shells.
# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
# and zshoptions(1) for more details.
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
it says , if you want to override then create ~/.zprofile.
touch ~/.zprofile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With