I want to write a shell script (zsh) that does the following:
- Installs Anaconda via Homebrew.
- Adds conda to PATH in
.zshrc
. - Updates conda base environment.
I have come up with the following solution:
# Installing Anaconda
if [ ! -d /opt/homebrew/Caskroom/anaconda ]; then brew install --cask anaconda; fi
# This adds conda to your PATH in .zshrc and makes sure that you can now use conda and activate conda environments
/opt/homebrew/anaconda3/bin/conda init zsh
# Sourcing zshrc
exec zsh
# Update conda base environment
conda update -n base -c defaults conda
The problem is, that exec zsh
replaces the current shell, so the conda update does not happen.
Is there a better solution to the problem?