102

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.

kenorb
  • 25,417
Idlecool
  • 1,438
  • 2
  • 15
  • 15
  • After changing shell to zsh, I still had to launch zsh manually. Logging out didn't help. I then changed zsh to the upmost login shell. Logged out and there it was. –  Dec 01 '11 at 16:06
  • 1
    If nothing else, you can always modify the .bashrc to find and exec zsh. 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. – Dan Pritts Sep 30 '13 at 13:23

6 Answers6

120

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.

kenorb
  • 25,417
Spiff
  • 104,423
  • 4
    I installed a newer version of zsh with Homebrew, which put zsh in /usr/local/bin/zsh. Unfortunately, chsh doesn't allow this, saying chsh: /usr/local/bin/zsh: non-standard shell. Daniel Beck's answer is a suitable solution in this case. – adam_0 Feb 02 '13 at 19:20
  • 43
    If 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. – Mike Meyers Feb 28 '13 at 10:57
  • 13
    The 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.
    – George Mar 19 '13 at 11:20
  • Doesn't work sometimes. @frank's answer ensures it though – oliverbarnes Jul 22 '15 at 17:06
  • /etc/shells is a read only file? doesn't let me edit it. – Awesome_girl Oct 04 '16 at 17:02
  • 1
    @Awesome_girl By default, /etc/shells is owned, and only writable by, root (the superuser). You could, for example, use sudo vi /etc/shells to use sudo (super user do) to run the vi 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. – Spiff Oct 05 '16 at 20:12
  • For Homebrew and fish, the path is /opt/homebrew/bin/fish – Elijah Lynn Jun 26 '23 at 22:52
64

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.

  1. Open "System Preferences" → "Users & Groups".
  2. Unless the lock icon is already unlocked, click the lock icon and authenticate yourself.
  3. 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).
  4. In context menu, choose "Advanced Options…".
  5. 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.

enter image description here

Qsigma
  • 166
  • 1
  • 7
Daniel Beck
  • 110,419
  • ouhp. bummer. :| – Idlecool Dec 01 '11 at 19:31
  • 1
    Confirmed that this works in Mountain Lion, as well as working with "non-standard shells" that you might install yourself (or have Homebrew install). – adam_0 Feb 02 '13 at 19:21
  • 3
    Confirmed still working in 10.10 Yosemite. – ecnepsnai Sep 08 '14 at 03:44
  • 4
    right click on the username to bring up the menu containing "advanced options". That took me a couple of minutes to find. – pdwalker Dec 16 '14 at 12:37
  • @pdwalker Right, I wrote this answer on the assumption that you read the question (and clicked the link there, which describes how to do this except for the name of the preference pane). – Daniel Beck Dec 16 '14 at 15:30
  • 1
    Why 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. – pdwalker Dec 19 '14 at 07:44
  • Seems to be for an outdated version of OSX. El Capitan doesn't have the context menu. – jvriesem May 05 '17 at 21:58
  • 1
    @jvriesem Actually, it does. My guess is you skipped step 2. – Daniel Beck May 05 '17 at 22:00
  • 1
    @DanielBeck: Sure enough! Thanks! I would have expected that the context menu would show regardless of authenticated status, but then that window would have a lock at the bottom. – jvriesem May 05 '17 at 22:10
  • Confirmed still works in macOS 10.13 High Sierra – Qsigma Dec 31 '17 at 20:49
  • This still works in macOS 12 Monterey. – bb010g Jan 07 '22 at 02:21
13

Or:

sudo dscl . change /users/$USER UserShell /bin/bash $(which zsh)
frank
  • 131
  • 1
  • 2
2

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.

Jezuz
  • 21
1

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
  • 1
    This 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 02 '16 at 12:16
0

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/

Can Rau
  • 241