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.
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
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.
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!
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.
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.
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!
Pressing tab does nothing, other than inserting... tab.
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.
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.
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
bash. phenomenal. kudos and thx to bashmeisterforlife b. fox ! !!
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.
That's okay; I eventually made my way to oh-my-zsh, too!
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 :)
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.
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.
Great article, many thanks for sharing the information :-)
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.
Are you using Hyper Terminal?
Yes, indeed it is Hyper.
What terminal is it that you're using?
This is hyper + a little bit of a custom config on top of that.
Hey there, thanks for the reply, i did some research and got the same look on iTerm2, whats your take on that editor?
It is very decent ! Probably much more reliable than Hyper :)
Great article...thanks dude 👍
I am glad that you enjoyed it.
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?
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.
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.
Being new to all this, I'm feeling happy about the fact that it seems easy to switch between shells on my new mac (and, I imagine, anywhere else they show up). But I'm still not clear on how it all works. For instance, I can change the default shell using the terminal settings. This seems to have happened automatically at some point when I was using Homebrew to download a bunch of stuff. I'm trying to use python to create a program that will operate a microcontroller with a sensor (and eventually an array of sensors). It was suggested that I download Homebrew, which I've done; it seems like this will make it easy to get different pieces of code (or should I say git?). It was suggested that I partition a drive on my computer that is case sensitive and big enough but also sparse, which I've done. However, circuitpython (a fork of micropython), which I'm using seems to have some needed parts that are only in bash (gmake and Python3), or at least the most recent versions that I can find are available there. Are there newer versions available in zsh? Is that what this whole open-source, github repo thing is all about? Are there downsides to reverting/keeping bash when it comes to regular MacOS applications? Or does the shell only impact the work that I do using the terminal?
btw, it seems likely that the "Tab" functions that some people say don't work will only work with "Oh My ZSH" and are not built in to zsh. I haven't tried it yet, but I think it might be useful once I have more stuff built and saved that I want to access.