I'm trying to change the Login Shell of Mac OS X from bash
to zsh
. I see it is possible in Mac OS X Leopard, but for OS X Lion I can't find a way. I really hope it is possible to change the Login shell from bash to something else. I am not exactly sure where to look for.
6 Answers
You can change user shell by the following command:
chsh -s /bin/zsh
Note: To change it for a non-standard shell, make sure its path has been added to /etc/shells
file.
-
4I installed a newer version of zsh with Homebrew, which put zsh in
/usr/local/bin/zsh
. Unfortunately, chsh doesn't allow this, sayingchsh: /usr/local/bin/zsh: non-standard shell
. Daniel Beck's answer is a suitable solution in this case.– adam_0Feb 2, 2013 at 19:20 -
43If you are getting problems with non-standard shells, I think you should be able to add
/usr/local/bin/zsh
to/etc/shells
and it should solve that problem. Feb 28, 2013 at 10:57 -
13The homebrew zsh install info does actually recommend you to add it to /etc/shells:
==> Caveats To use this build of Zsh as your login shell, add it to /etc/shells.
– GeorgeMar 19, 2013 at 11:20 -
-
1@Awesome_girl By default,
/etc/shells
is owned, and only writable by, root (the superuser). You could, for example, usesudo vi /etc/shells
to usesudo
(super user do) to run thevi
editor to edit/etc/shells
. I just tested on my system and confirmed that it is NOT protected by System Integrity Protection, so you should be able to edit it as root without jumping through hoops to disable SIP.– SpiffOct 5, 2016 at 20:12
Funnily enough, the same method you link to in your question still works in OS X Lion through Sierra (10.12). The only difference: The preference pane is named Users & Groups instead of Accounts.
- Open "System Preferences" → "Users & Groups".
- Unless the lock icon is already unlocked, click the lock icon and authenticate yourself.
- Context-click on a user in the list of user names (hold down the Control key while clicking, or right-click on a right-handed two button mouse).
- In context menu, choose "Advanced Options…".
- Choose "Login shell" in the sheet that appears.
The note at the top of the "Advanced Options" screen claims you have to restart for the change to take effect, but you really just need to log out and back in again.
-
1Confirmed that this works in Mountain Lion, as well as working with "non-standard shells" that you might install yourself (or have Homebrew install).– adam_0Feb 2, 2013 at 19:21
-
3
-
4right click on the username to bring up the menu containing "advanced options". That took me a couple of minutes to find.– pdwalkerDec 16, 2014 at 12:37
-
1Why force someone to go offsite to gather all the information before being able to the answer? Hence the comment in case someone else makes the same assumption that the answer is here rather than here and there.– pdwalkerDec 19, 2014 at 7:44
-
1
Or:
sudo dscl . change /users/$USER UserShell /bin/bash $(which zsh)
-
3
-
-
3Also, be careful that the path of zsh installed via homebrew is different. I do it as:
sudo dscl . change /users/$USER UserShell /bin/bash $(which zsh)
Mar 25, 2015 at 13:42 -
1WARNING: This will break your shell if you copy / paste it without checking the path of zsh first. Do what metakermit said instead. Apr 4, 2016 at 13:51
An update, on Ventura, you can either use dscl as people have described above, or go into the system settings and control click (or right click) on your user name. You will then be able to choose advanced options and from there add your shell as the login shell. But be careful so that you do not break anything.
-
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review Dec 12, 2022 at 13:24
If anyone wondering same problem happens on macOS Sierra and following command allowed me to change shell without problems:
chpass -s /usr/local/bin/zsh
-
1This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. "chfn and chsh are synonyms for chpass."– DavidPostill ♦Dec 2, 2016 at 12:16
Running this
sudo dscl . -create /Users/$USER UserShell /usr/local/bin/zsh
worked for me to fix
(eval):setopt:3: no such option: NO_warnnestedvar
which popped up everytime autocomplete should kick in
found in https://rick.cogley.info/post/use-homebrew-zsh-instead-of-the-osx-default/
if [ -x /usr/local/bin/zsh ] ; then exec /usr/local/bin/zsh fi
. Hint, when modifying shell startup scripts, make sure to keep a shell running and start up a new one in another window - if you break it you still have an easy place to fix it.