1. 30

macOS Catalina is changing the default shell to zsh.

  1. 6

    Fun fact: NEXTSTEP came with zsh, but not as the default shell. I guess this change has been overdue for decades.

    1. 6

      If bash was still on GPLv2, they would not have done this change.

      1. 0

        I wish they’d take off their tin foil gpl hats.

        1. 7

          From 1990 to 1995, the FSF boycotted Apple over their intellectual property activities. At the time, the hot issue was the copyright lawsuits which ultimately led to the look-and-feel doctrine which is still in place today. When the GPLv3 was published in 2005, it included substantial new provisions related to patents, since use of patents was at the time one of the largest ways the free software community felt mistreated by large corporations, and indeed Apple was among the companies that had been criticized in that regard. I’m sure Apple’s lawyers feel that to some extent these provisions are targeted at them, and I think there’s some truth to that.

          As an individual, I support the FSF’s position here, but I understand why Apple as a corporation is wary of it, and I don’t think they’re being irrational. Both Apple and the FSF are focused on the long-term, so their actions do seem a little silly when we look at the day-to-day, but they’re each acting in accordance with their purpose and incentives.

        2. -1

          zsh was the default shell for 10.2 or 10.3 iirc, so in a way this is just switching back to zsh as the default shell.

          1. 5

            tcsh was the original default shell prior to bash, not zsh. Wilfredo Sanchez, former tcsh dev, was Lead of the Unix Technologies team at Apple during that era

            1. 1

              Could be, been a long time since I ran 10.2 so maybe my brain is just having an old person fart.

        3. 2

          NEXTSTEP was so ahead of its time in Sooo many ways.

        4. 3

          Long time ago, I used to use zsh as my login shell on anything from Linux, macOS - Mac OS X back then ;^) - through to Solaris. Now, /bin/ksh on OpenBSD is all I need, and don’t spend enough time on macOS to warrant any deviations from certain defaults. It’s nice to see zsh becoming the default login shell on new macOS, though.

          1. 2

            I actually use OpenBSD’s ksh on Mac thanks to https://github.com/ibara/oksh

            1. 1

              I use zsh interactively but still target my scripting to ksh out of habit. While OpenBSD ksh is fantastic, everywhere else I use mksh.

            2. 2

              I love zsh, but this is kinda frustrating, because significant chunks of the working world still treat bash as the bog standard.

              I mostly don’t care. I’m an adult and can change my shell, but I still don’t love this move.

              Probably going to jump ship to Linux for my work machine when this laptop dies anyway ;) I find myself way more comfortable with KDE these days.

              1. 1

                I remember reading about zsh’s startup and prompt latencies being considerably worse than bash but can’t recall where (either Github Issues comments or a Dan Luu-like post.) In any case:

                echo "Changing shell to brew's bash. . ."
                brew install bash
                echo "$(brew --prefix)/bin/bash" | sudo tee -a /etc/shells > /dev/null
                chsh -s $(brew --prefix)/bin/bash
                1. 3

                  Funny, I thought the performance issues were the other way around.

                  I certainly notice that bash’s completion is considerably slower than zsh.

                  1. 2

                    I’ve been a zsh user since the early 1990s, maybe 1992 or so, and never really used bash as I was a ksh user previously, so perhaps my observances can be taken with a grain of salt - but I think the problem here is that a lot of people turn on oh-my-zsh (or similar) and enable every plugin and option and then wonder why the shell takes forever to start up.

                    I do use oh-my-zsh, and for zsh 5.3.1 on a Raspberry Pi 3B, average (over 10 startups) startup time is 0.714s, this is compared to 0.204s for (uncustomized beyond Debian defaults) bash, 0.176s for tcsh, and 0.008s for mksh. Uncustomized zsh actually launches slightly faster than uncustomized bash

                    Also, once the shell is running, I find zsh performance (in areas like globbing and completion) to be quite speedy, but I’ve never benchmarked against bash.

                    Edit: After upgrading to zsh 5.7.1 (from 5.3.1), startup time is, on average, 215ms faster - startup in ~500ms on average.

                    Profiling shows the speed improvement is faster completion initialization.

                    1. 1

                      My 85-line .zshrc, with some fancy-ish prompt stuff, some functions and alises, but no framework like OMZ has an average start time of 0.058s. On the same system, bash in its default configuration (as provided by the FreeBSD package) is about 0.008s.

                      I’ve never understood the need for frameworks for my shell. I can implement the same functionality with much less overhead.

                      1. 1

                        The framework isn’t very heavy unless you enable all sorts of thing you likely won’t use.

                        Using the zsh profiler (add zmodload zsh/zprof as the first line of your .zshrc, and zprof as the last), I can see that ~50% of my startup overhead is related to completion, and another 30% is related to zsh-syntax-highlighting (which can be slow in usage, but not annoyingly so).

                        I don’t see a need to try to optimize the remaining 20% by profiling parts of oh-my-zsh or trying to avoid it. (I do use some of it’s plugins and then unset or reset a few of the aliases, however, so there is some low hanging fruit in that 20%.)

                        As this is a comparatively slow CPU, where your numbers are probably for a modern desktop, you’d be even less likely to notice the overhead from the framework. It’s not all that heavy.

                    2. 1

                      To be honest, I don’t know much about bash completion because I don’t use it. Standard tab for directory autocomplete with the following Readline settings is all I need.

                      set show-all-if-ambiguous on
                      set completion-ignore-case on
                      set mark-symlinked-directories on
                      set colored-stats on
                      set completion-prefix-display-length 3
                    3. 1

                      Ha! I just had to do this last week when something broke my completions and I realized it was easier to install and use bash from Homebrew than it was to find a workaround for my actual problem. My overengineered solution is here.

                      1. 1

                        I do something similar in my dotfiles setup script.

                    4. 1

                      I used to use zsh as my default shell a long time ago and had a nifty setup before zsh frameworks were a thing. I went back to bash after I migrated to Mac and was too lazy to switch my login shell to zsh on every Mac (and I wasn’t sure if Mac things would break in weird ways from doing so).

                      It’s interesting to see this change happening. Apple has held bash back for years because of the GPL.

                      1. 0

                        Sell me zsh. A few friends use it but they’ve not been able to clearly convey its advantages over ye olde bash that is just… everywhere.

                        1. 4

                          auto completion works even if you don’t type the string from the beginning. i.e. you have a series of folders




                          you can do an ls and start typing videos and it will tab-autocomplete to the right folder. It was the one feature that signaled to me, you made a good decision to switch.

                          1. 2

                            If bash is good enough for you then you probably have no reason to switch.

                            In the past I used zsh for some of its fancier features: I could do more expressive expansions to make my prompt pretty or do clever directory chomping; I found its completion much faster than bash, but that’s only useful if you use flag or subcommand completion; menu completion can be useful. I think also the history settings in zsh were or are more featureful than bash, but I’m not entirely sure what bash’s current features are like.

                            I’ve been using bash just fine for the last ~10 years on personal systems but I do have zsh on some servers so that I can do more clever things with prompting.

                            1. 2

                              The main reason I used zsh was to handle correctly files with special chars in them ([ \t\n] for example). It also has “real” lists and associative arrays. Mainly it was often better to write scripts. After I also found that print in zsh is often better than echo. For example print -P "%Bsomething bold%b". Also things like ${fic:t} instead of basename $fic, ${fic:s/x/_/} instead of echo $fic | sed 's/x/_/' and a lot of small niceties.

                              I no longer use zsh as my main shell, I switched to fish. Still I always preferred zsh over bash. But it was a long time ago, perhaps bash is better now.

                              I use fish for basic usage (completion is great), but when I script I generally use zsh.

                              1. 1

                                I’d start with the zsh-lovers document.