Making ZSH default Shell in MacOSX [closed]
The correct answer should've addressed your problem:
chsh: /usr/bin/zsh: non-standard shell
The reason this is the case is because chsh
will only accept shells that are defined in the file /etc/shells, as you can see by reading the manual for chsh
:
chsh will accept the full pathname of any executable file on the system. However, it will issue a warning if the shell is not listed in the /etc/shells file.
To solve this problem and make zsh the default shell, you should thus:
$ sudo echo "$(which zsh)" >> /etc/shells
$ chsh -s $(which zsh)
Obviously, I assume that zsh
is in your path here. This solution will also work if you, for example, choose to install the latest zsh
with brew install zsh
.
EDIT (thanks for ThisIsFlorianK for the comment):
Depending on your shell setup you may get a message saying /etc/shells: Permission denied
. You can find information about this issue here.
To work around it, use the following instead:
$ sudo sh -c "echo $(which zsh) >> /etc/shells"
$ chsh -s $(which zsh)
The three easy steps:
-
which zsh
this gives you your path to zsh - Then
chsh -s /bin/zsh
or replace path to your zsh if different - Restart your machine
I was able to get this working by doing the following:
- Go to System Preferences
- Click on "Users & Groups"
- Click the lock to make changes.
- Right click the current user -> Advanced options
- Change the login shell to /bin/zsh in the dropdown.
- Open a new terminal and verify with
echo $SHELL
On my work MacBook I had to do this:
sudo chsh -s /usr/local/bin/zsh my_user_name
Then I had to create a .bash_profile
file to make my terminal switch to z-shell every time I open it:
touch ~/.bash_profile
echo 'export SHELL=$(which zsh)' >> ~/.bash_profile
echo 'exec $(which zsh) -l' >> ~/.bash_profile
The last idea was borrowed from here.