Skip to content

Apple changed the default shell from bash to zsh, so did I

Announced at WWDC 2019 (Worldwide Developers Conference), macOS Catalina comes with a lot of changes but in all honesty, I didn’t expect switching the default shell to zsh (Z shell). Since OS X 10.2 Jaguar released in 2002 bash has been the primary operating system shell, so why all the sudden this change? Long story short — licensing.

Bash in version 3.2.57 on macOS Mojave

Newer versions of Bash are licensed under the GPLv3 (GNU General Public License version 3) which says you can’t use it on a system that blocks 3rd party software installation. That’s the reason why macOS stuck with 3.2.57 version released under GPLv2 which dates back to 2007. Licensed under the MIT License Z shell allows Apple to ship regular updates to this command language and keep a great level of compatibility with Bash.

Because this is the future of my operating system, I spent some time to explore a new shell. Let me share with you how to do it and point out some things that I like the most about the new default shell language.

Change your default shell #

Fresh installation of macOS Catalina will default to Z shell but an update from the previous version of Apple OS will persist your preference. It is very simple to update this setting though. You have a few options to do so: chsh CLI tool, Users & Groups panel of System Preferences or Directory Utility built-in app.

chsh -s /bin/zsh

Change the default login shell on macOS

Cool things about zsh #

While zsh is mostly feature-compatible with bash there are some minor differences between them. On top of that modern Z shell comes with a lot of useful user experience improvements. Let me share a few of my favourite bits.

Flexibility and open-source resources #

Z shell comes with tons of options that allow you to make your prompt really yours. If you are not a big fan of crafting config files manually, there is several popular open-source tools that help you manage your Zsh configuration. Bundled with hundreds of helpers, plugins and themes Oh My ZSH is by far the most popular one.

Several great zsh frameworks

Supercharged auto-completion #

Not only can you skip cd to change your current working directory but you can type a path in an extremely lazy way and press then tab. No need for cd Sites/projectname/src anymore because s/p/s is more than enough. This feature is enabled by default on Oh My ZSH framework but you can control it manually using AUTO_CD option. Look!

Supercharged auto-completion with zsh

This feature is mind-bending. To explore current location just press tab twice to traverse through inner folders using arrow keys. This feature is part of Oh My ZSH.

Supercharged auto-completion with zsh

Discover a commands options / flags #

There is no need to check the man page of a particular command to find a flag that you want to pass. Just type command name - and press tab to discover all possible options and flags.

Supercharged auto-completion with zsh

It is the default on macOS #

Since macOS Catalina it’s the default one, so you don’t have to do anything to use it. It is fantastic, isn’t it?

What do you think about zsh? #

What is your take about Apples recent decision? Do you use zsh or bash? What are your favourite features? Let me know in the comments below. Until next time, happy coding!

Comments

  • J
    Joanna Yossarian

    Pressing tab does nothing, other than inserting... tab.

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
  • B
    Brian Fox

    If (like me) you don't wish to stop using bash as your default shell, because (like me) you use bash on every environment that you work in, and find it to be a fine shell, then `brew install bash`.

    $0.02 from the author of Bash.

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • J
      Jim Derry

      If you're the real Brian Fox, then this is awesome, because bash is awesome, and it looks like you got here just a few hours before I did. I landed here trying to learn about my new default shell. None of the examples work for me, by the way. I might give zsh a try, but 25 years of bash is going to be hard to get away from.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
      • B
        Brian Fox

        Yeah, it's me. Listen, there's nothing wrong with zsh - it has a POSIX compatible mode, so it is line with the specification that I was part of creating. It generally has the same convenience features that bash has, but it doesn't use readline, which means that shared library's configuration file (~/.inputrc) won't work. It also has a more screen oriented usage for completion as opposed to a command-line oriented method (which might be more to some people's taste). However, bash is released under the GPLv3, which says you can't use it on a system that prevents the installation of 3rd party software -- a practice that Apple has been getting closer to for a decade or so. And, this: "between MacOS 10.5 Leopard and MacOS 10.12 Sierra, the number of GPL-licensed packages that came pre-installed on macs decreased by an insane 66 percent – from 47 to just 16." ref: https://thenextweb.com/dd/2019/06/04/why-does-macos-catalina-use-zsh-instead-of-bash-licensing

        👆 you can use Markdown here

        Your comment is awaiting moderation. Thanks!
        • e
          en zyme

          bash. phenomenal. kudos and thx to bashmeisterforlife b. fox ! !!

          👆 you can use Markdown here

          Your comment is awaiting moderation. Thanks!
      • Pawel Grzybek
        Pawel Grzybek

        I published this article during my very early exploration of zsh. Some of the stuff presented on this article is a part of oh-my-zsh framework, not necessarily a raw zsh. I am sorry if some of the examples didn't work as expected, I will update this article soon.

        👆 you can use Markdown here

        Your comment is awaiting moderation. Thanks!
        • J
          Jim Derry

          That's okay; I eventually made my way to oh-my-zsh, too!

          👆 you can use Markdown here

          Your comment is awaiting moderation. Thanks!
          • Pawel Grzybek
            Pawel Grzybek

            Thats cool. Thats was the case for me. I added oh-my-zsh when I started using zsh.

            Recently I removed it because it caused some delays on my shell.

            Good luck :)

            👆 you can use Markdown here

            Your comment is awaiting moderation. Thanks!
  • M
    Max

    I tried the shortcuts listed here, literally not a single one of them worked. The only way to get them to work is to install Oh My Zsh. The features listed here are not part of the default Zsh shell.

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • Pawel Grzybek
      Pawel Grzybek

      I am very sorry for confusion. Some of them rely on oh-my-zsh — you are right. Some of them are part of the zsh but need to be enabled using `setopt`. I will update this article asap to avoid this unnecessary confusion.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
      • M
        Max

        Great article, many thanks for sharing the information :-)

        👆 you can use Markdown here

        Your comment is awaiting moderation. Thanks!
    • Pawel Grzybek
      Pawel Grzybek

      Hi. I updated this article. I clearly highlight which feature comes from Oh my zsh, and if not what options is responsible for it.

      Sorry again for any inconveniences.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
      • U
        Uzair

        Are you using Hyper Terminal?

        👆 you can use Markdown here

        Your comment is awaiting moderation. Thanks!
        • Pawel Grzybek
          Pawel Grzybek

          Yes, indeed it is Hyper.

          👆 you can use Markdown here

          Your comment is awaiting moderation. Thanks!
  • P
    Paul V. Bernard

    What terminal is it that you're using?

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • Pawel Grzybek
      Pawel Grzybek

      Hi Paul.

      This is hyper + a little bit of a custom config on top of that.

      Hyper:
      https://hyper.is

      Config:
      https://github.com/pawelgrz...

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
      • P
        Paul V. Bernard

        Hey there, thanks for the reply, i did some research and got the same look on iTerm2, whats your take on that editor?

        👆 you can use Markdown here

        Your comment is awaiting moderation. Thanks!
        • Pawel Grzybek
          Pawel Grzybek

          It is very decent ! Probably much more reliable than Hyper :)

          👆 you can use Markdown here

          Your comment is awaiting moderation. Thanks!
  • R
    Ryan Davis

    Great article...thanks dude 👍

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • Pawel Grzybek
      Pawel Grzybek

      I am glad that you enjoyed it.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
  • B
    Bark Kreative

    So rad. Great article, explained perfectly! Thank you. I dig it. Oh, I forgot to ask. Would this change effect any of our permissions at all? We're having issues dragging files over to like our external hard drive and dropbox folders. It's telling us we don't have administration rights anymore. Could that be because it was bash and now we're zsh?

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • Pawel Grzybek
      Pawel Grzybek

      Sorry, I don't know about the subjest ebnough. Personally I doubt it is related with this change. It is more like a groups / permission change across shared directories.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
      • B
        Bark Kreative

        Thank you! We figured out the external drives. The software is no longer supported by Apple. They're phasing out all 32bit software in favor of the 64.

        The other issue seems to be DropBox when it's in the sidebar of finder. For now we're back on track, but was hoping to find a solution. Thank you.

        👆 you can use Markdown here

        Your comment is awaiting moderation. Thanks!

What'ya think?

👆 you can use Markdown here

Your comment is awaiting moderation. Thanks!