0

macOS will be using zsh moving forward and we can set zsh as the default shell in Catalina which I have done. With Catalina is it ok if I remove all traces of bash and oh-my-zsh since zsh is now the default shell? Also I am using Hyper Terminal which means I do not need oh-my-zsh any longer right.

Example:
The Anaconda installer added this script originally to my bashrc or bash_profile so I copied it over to .zshrc when I switched to zsh. I recently read I didn't need to/shouldn't have copied it over since it was meant for the bash_profile but now that macOS is moving to use zsh anyway I'd like to know what I should do. Obviously I need to tell zsh where Anaconda is but do I need that script or can I just export the Anaconda path like export PATH=/Users/ty604/anaconda3/bin:$PATH?

Can I just leave this Anaconda script in zshrc and remove all traces of bash to future-proof my Mac when bash is gone?

export PATH=/Users/ty604/anaconda3/bin:$PATH

# added by Anaconda3 2019.03 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/ty604/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/ty604/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/ty604/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/ty604/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

I also have many duplicate paths in $PATH because of duplicate export commands in various shell files.
$ echo $PATH
/Users/ty604/anaconda3/bin:/Users/ty604/anaconda3/condabin:/Users/ty604/anaconda3/bin:/Users/ty604/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/Users/ty604/flutter/bin

Files in my system
.bash_history, .bash_profile, .bashrc, .profile, .zprofile, .zsh_history, .zshrc, .zshrc.pre-oh-my-zsh

Folders in my system
.bash_sessions, .oh-my-zsh, .zsh

  • 3
    As far as I know, bash is not going away on macOS. It's just that zsh (which has been part of macOS for some time) is now the defualt login shell. You should not try to "delete bash" from your system, as that may well break stuff (/bin/sh is still bash, for example). – Kusalananda Dec 28 '19 at 11:44
  • Yes it is going away because of licensing. That's why zsh has become default. – Edison Dec 28 '19 at 11:45
  • There is nothing bash-specific in that Coda setup code. Are you having issues with it under zsh? – Kusalananda Dec 28 '19 at 12:08
  • I also don't see any duplicated entries in your $PATH. What is your question? – Kusalananda Dec 28 '19 at 12:19
  • If you take a look, there are two instances of /Users/ty604/anaconda3/bin. I am assuming that is because export PATH=/Users/ty604/anaconda3/bin:$PATH is in more than one shell file such as .zshrc and .bashrc. And actually I found it in .bash_profile as well. Since zsh is my default shell and Catalina defaults to zsh can I remove that export from .bashrc and .bash_profile? And can I remove any bash and oh-my-zsh files since my default is now zsh + Hyper? – Edison Dec 28 '19 at 12:42
1

The shell initialisation code that you show does not look bash-specific and should work with zsh as well, assuming that the various script that it sources are working too (shell.bash and conda.sh). If there is a shell.zsh script you could obviously choose to use that instead of shell.bash.


In the zsh shell, the PATH variable is tied to the path array. You can make both contain only unique entries using typeset -U.

This is an example using your particular value of for PATH:

$ print -rC1 -- $path
/Users/ty604/anaconda3/bin
/Users/ty604/anaconda3/condabin
/Users/ty604/anaconda3/bin
/Users/ty604/.cargo/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/VMware Fusion.app/Contents/Public
/usr/local/share/dotnet
/Users/ty604/flutter/bin

The path /Users/ty604/anaconda3/bin is duplicated at the start. To make the paths unique (now and in the future):

$ typeset -U PATH path
$ print -rC1 $path
/Users/ty604/anaconda3/bin
/Users/ty604/anaconda3/condabin
/Users/ty604/.cargo/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/VMware Fusion.app/Contents/Public
/usr/local/share/dotnet
/Users/ty604/flutter/bin

See also what happens if I push /bin onto the start of the path:

$ path=( /bin $path )
$ print -rC1 -- $path
/bin
/Users/ty604/anaconda3/bin
/Users/ty604/anaconda3/condabin
/Users/ty604/.cargo/bin
/usr/local/bin
/usr/bin
/usr/sbin
/sbin
/Applications/VMware Fusion.app/Contents/Public
/usr/local/share/dotnet
/Users/ty604/flutter/bin

(The second /bin is deleted.)

Since the path array is tied to the PATH variable, the changes will be visible there too:

$ print -rC1 -- $PATH
/bin:/Users/ty604/anaconda3/bin:/Users/ty604/anaconda3/condabin:/Users/ty604/.cargo/bin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/Users/ty604/flutter/bin
| improve this answer | |
  • ok those are handy commands. Thanks! But since zsh is now default on >macOS 10.15 can I remove all bash related files such as .bashrc, .bash_profile, .bash_history etc? And what zsh files are absolutely necessary? Only .zshrc or .zprofile as well? – Edison Dec 28 '19 at 13:05
  • @tem I would move them away rather than removing them, just until such time that you've noticed that nothing seems broken. zsh does not use the bash init files. Only .zshrc is necessary (the shell will print out a short message if it's not present) but it could be empty. Just like with bash, you have different init files for login shells and for interactive shells. .zprofile is similar to .bash_profile and .zshrc is similar to .bashrc. This is covered in the manual under "STARTUP/SHUTDOWN FILES". – Kusalananda Dec 28 '19 at 13:09
  • 1
    Yes I realize that .zprofile / .bash_profile and .zshrc / .bashrc are similar. I don't use .bash_profile so I was thinking I don't need .zprofile either. Yes, I mean move and save the files rather than delete. As long as it's safe to move them and test than I will move them. Lastly, what about that Anaconda script? It refers to shell.bash. Maybe I can change that line to shell.zsh and then move all bash files? Or just comment out the script and only use export PATH=/Users/ty604/anaconda3/bin:$PATH? – Edison Dec 28 '19 at 13:15
  • @tem If there is a shell.zsh, you should use that. Otherwise either try the shell.bash script or inspect what it does and do similarly manually. If setting the PATH like you show is all that it does, then by all means do that. – Kusalananda Dec 28 '19 at 13:58
0

I have since found out that zsh does have a hook which means I can remove all instances of bash shell since the system $PATH is being sourced from etc/profile anyway.

macOS default shell is now zsh so for me, there is no use for bash files.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.