9 ms·
Use zsh as the default shell on your Mac
- SomeOldThrow 7y agoI'm really surprised they went with zsh rather than fish. I guess they want to preserve the ability for existing `source` scripts to work.
- tptacek 7y agoWhy would they use fish? Fish is nice and all, but zsh is a much more mainstream shell.
- SomeOldThrow 7y agoSince when is mainstream better? Why did they choose zsh? They don't justify that either. It's just odd to pick one post-bash shell but not the other when they have very similar feature sets—autocomplete, persistent global variables, attention to end-user quality. EDIT: apparently zsh doesn't have persistent or global variables, my bad.
- GavinMcG 7y agoMainstream is often better in terms of unofficial support/learning resources, and by definition better in terms of familiarity/market share. For something like a shell, forcing a niche choice needs justification when it's not clearly better than the alternatives.
- SomeOldThrow 7y agoFish is clearly better than the alternatives.
- nikeee 7y agoWell, fish is not compatible to bash. Users would suddenly face bash-one-liners that they find on StackOverflow to stop working.
- latexr 7y agoMost Terminal users might not even notice the shell changed from Bash to ZSH. Those same users would notice it, had they changed it to Fish.
- SomeOldThrow 7y ago> Most Terminal users might not even notice the shell changed from Bash to ZSH. If that's an argument in favor of ZSH, I think I've missed the point.
- latexr 7y agoIt’s an argument in favour of ZSH over Fish. It will cause less disruption, while providing better features than the current default.
- SomeOldThrow 7y ago> while providing better features than the current default. Barely—it doesn't address any fundamental issues with bash, it's basically a coat of paint. It does make sense that tech companies are only into disruption if they can profit from it.
- Sean1708 7y agoThe point is that apple don't want to update bash because they don't want to ship software that uses GPLv3 but they also don't want to keep shipping a decade old version of bash as the default shell, they aren't doing this because they want to improve on bash or anything like that.
- spartanatreyu 7y agoThere's already a lot of community support available for zsh. Plenty of developers are using oh-my-zsh either for just the plugin support or for the very popular iterm+powerlevel9k+agnoster theming.
- yborg 7y agofish is friendly.
- celeritascelery 7y agoAnd interactive.
- bangonkeyboard 7y agofish was written by an Apple engineer.
- nhooyr 7y agoIt's really annoying to have to learn new language when zsh is so similar to bash.
- SomeOldThrow 7y agoIt's really annoying to learn bash, so I don't see how that works in zsh's favor.
- eropple 7y agoTo be honest I'm hesitant to respond to you because of the level of spittle-flecking you're doing in this thread but I would guess that, by virtue of bash being the standard Mac shell and zsh being a close-enough-but-better replacement, the necessary learning has already happened and overwhelmingly more Mac terminal users will be at least functional with it immediately.
- daveidol 7y agoNot the OP, but I agree with both of you actually. It's easier in many ways to run a POSIX-compliant shell with a more "familiar" scripting language to bash users (especially when it comes to running existing scripts or one-liners you find online).... buuuut at the same time I think it's pretty clear that fish's scripting language is much more modern and "better" in many ways.
- eropple 7y agoI don't write shell scripts for nontrivial things and it's rare that I see a good reason to, so I'm not sure that moves the needle much. It's 2019, we have other scripting tools, etc.
- daveidol 7y agoHmm, I see your point, but on the other hand: is that really a good reason to continue the status quo of shell scripting if there are improvements to be made? Being practical about it: if you install fish you can also install bash, and then running a bash script is as simple as `bash script.sh`, so you can have your cake and eat it too. Although, in this particular instance, if Apple is going to cease shipping bash at all, I can see why this would be annoying out of the box.
- maximente 7y agoas far as i know !! does not work on fish, which means it's dead in the water (had to) as far as i'm concerned.
- daveidol 7y agoDiscussion on the topic: https://github.com/fish-shell/fish-shell/issues/288 https://github.com/fish-shell/fish-shell/issues/288 And, a omf plugin if you want: https://github.com/oh-my-fish/plugin-bang-bang https://github.com/oh-my-fish/plugin-bang-bang
- hestefisk 7y agoExactly, compatibility. fish has a somewhat different syntax to bash.
- m45t3r 7y agoI think it is mainly because `fish` is incompatible with everything. Most `bash` scripts runs fine in `zsh` (`zsh` has even a `bash` compatibility mode, not necessary generally because rarely `zsh` and `bash` diverges), no `bash` script runs fine in `fish`.
- leadingthenet 7y agoMany of my `bash` scripts run just fine in `fish`, especially since v3 released.
- deleted 7y ago[deleted]
- jtms 7y agoI really like fish and had a pretty good run using it, but I have found myself on zsh for quite a few years - it’s just less friction to go with the herd on this particular part of my toolbox
- mhd 7y agoAs MacOS is a certified Unix, like the workstations of days gone by, they should've gone all out enterprise and switched to ksh. Heck, the new Mac Pro is even priced like a SGI/AIdX box.
- kccqzy 7y agoIt's probably because the default bash is a very ancient version before FSF transitioned to GPLv3. That said, I've been using zsh for a long time and this is a great change.
- jlawer 7y agoGuess they had to go somewhere as Apple's unwillingness to have GPLv3 code effectively killed off bash updates. Slightly disappointed, but guess they had to go somewhere and zsh is going to be well supported going forward
- bayareanative 7y ago??? # change default shell to newer brew'ed bash brew install bash && sudo dscl . change /users/$USER UserShell /bin/bash /usr/local/bin/bash # change default shell to newer brew'ed zsh brew install zsh && sudo dscl . change /users/$USER UserShell /bin/bash /usr/local/bin/zsh
- TylerE 7y agoWhat's your ??? That's homebrew, not Apple.
- bayareanative 7y agoSo? Apple doesn't ship updated packages. It never did. If you want updates, you use a package manager, not Apple's ancient crap. That's life.
- javagram 7y agoApple stopped shipping updated packages because bash went GPLv3... Since ZSH is under an MIT-like license, they’ll probably ship updates to it.
- eridius 7y agoThe version of /bin/zsh on macOS 10.14.5 is a little over 2 years old. This means they have already been shipping updates to it. Now that it's the default shell they'll probably ship updates a little more frequently (I don't have Catalina installed but I'm guessing its version of zsh is newer than 5.3).
- 7y ago
- latexr 7y agoFinally! Though I will say I’m surprised. I’ve opened a radar suggesting this change and it was closed with (paraphrasing) “won’t do it as the user can easily change the shell, I myself do it”.
- youeseh 7y agoFor the uninitiated: why is zsh better than bash?
- latexr 7y agoThe uninitiated won’t notice much of a difference, and that is bound to be the point. Bash on macOS is stuck at version 3 due to licensing reasons (GPL3), while ZSH is not (MIT).
- bsimpson 7y agoFor even more historical context, macOS originally shipped with tcsh. We've already done the shell transition once, and basically nobody noticed.
- koenigdavidmj 7y agoThat wouldn’t have broken as much, since everyone’s scripts would have a bash or sh shebang line on top. Changing what /bin/sh points to is a much riskier change.
- okdana 7y agoIs that what they've done? The linked article doesn't say that.
- brirec 7y ago$ /bin/sh --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19) Copyright (C) 2007 Free Software Foundation, Inc.
- koenigdavidmj 7y agoYou can change this by pointing /var/select/sh .
- 7y ago
- Newtonip 7y agoFor those wondering why Apple is allergic to GPLv3 code: there is a clause in the license requiring you provide a way to run modified version of the software which would require Apple to let users self sign executables.
- icedchai 7y agoSorry, how is that a problem? Users can build and execute code on their own Mac with XCode.
- Cyberdog 7y agoI don't really understand the licensing issues that well, but if what the poster above you said is true, I wouldn't really want to have to sign software that ships with my computer when it should just run out of the box.
- musicale 7y agoI don't understand why GPLv3 would be a problem on macOS. On macOS, you can run anything out of the box (depending on security/gatekeeper settings) and you can replace or modify system executables (such as /bin/bash) if you turn off SIP (which is slightly tricky to do but can be done from recovery mode.) Running your own customized /usr/local/bin/bash is easy of course, and package managers like MacPorts or Brew make it simple to install various shells including the latest bash. On iOS, however, there might be an issue, as you have to sign executables with XCode, but unfortunately Apple reduced free developer provisioning profiles from one year down to two weeks in order to block third-party app stores and malware, and to get more people to sign up for the paid developer program. Moreover, there is also no Apple-sanctioned way to modify system executables that I am aware of.
- 1over137 7y agoDid you notice how many qualifiers you had there? The trend on macOS is clear: harder and harder to run/do anything that isn't blessed by Apple.
- yokohummer7 7y agozsh is better than bash in nearly all aspects, at least in my use cases, so this is a great news for me. Is there anything that can be done in bash but not in zsh?
- iguessthislldo 7y agoI've been using zsh on Linux for years (4 at least). I was creating a function that I wanted to run in zsh and bash and I think I ran into some option that was available on a builtin command in bash that wasn't on the zsh version. I can't remember the details though, because it was a while ago. I imagine if someone deals with shell scripts more regularly than I do they would run in to those kind of problems more than me.
- Redoubts 7y agoNo, I think zsh is strictly more feature rich at the cost of a little more memory (like 1MB maybe). For macs this should be irrelevant.
- okdana 7y agozsh isn't a perfect super-set of bash (there are some differences in syntax, provided built-ins, &c.), but it does have equivalents for most of bash's functionality. Off the top of my head i can't think of anything useful that it's missing. People may have subjective preferences for e.g. readarray over parameter expansion, but the functionality is all there. I suppose it doesn't (and probably never will) fully conform to POSIX, if that's important to you
- grumdan 7y agoThe only thing I noticed in 10 years of zsh use is that `printf "%b\n"` can be used in bash but not in zsh to unescape C-style strings: E.g. `printf "%b\n" '\"abc\"'` ==> "abc"
- hestefisk 7y agoI still fondly remember when tcsh was the default shell. Like a real BSD Unix.
- reaperducer 7y agoIt's still in there. The linked article tells how to do it. In Terminal, enter $ chsh -s path, where path is one of the shell paths listed in /etc/shells, such as /bin/zsh, /bin/bash, /bin/csh, /bin/dash, /bin/ksh, /bin/sh, or /bin/tcsh.
- hestefisk 7y agoIndeed. The point was it was the default shell, being true to its heritage.
- Cyberdog 7y agoAnd you can use MacPorts or (presumably) Homebrew to install newer versions of tcsh or pretty much any other shell you might want. I personally never stopped using tcsh after the bash switchover since it's what I knew and what my dotfiles were already written in, and I'll most likely just keep using it in Catalina too.
- deleted 7y ago[deleted]
- w0mbat 7y agoYes, tcsh was the default in 10.0 then in 10.3 they changed it to bash.
- notacoward 7y agoI still not-so-fondly remember when csh was the default shell, on a real BSD-from-Berkeley can't-call-it-UNIX. :-P
- rsynnott 7y agoMaybe I’m imagining things, but wasn’t zsh also the default until MacOS 10.4 or so? Edit: I was misremembering things. tcsh until 10.3.
- jasone 7y agozsh was the default sh until OS X 10.2 or 10.3. However, the zsh version was quite out of date (3.x when 4.x was already mature/stable, IIRC). A horse race between the old zsh and the latest bash was jiggered to show bash as much faster, and therefore worth switching to, never mind that the then-current zsh demonstrated performance parity with bash. Source: I was tasked with the performance comparison and (despite my objections) the conversion to bash. On the bright side, I learned a lot about zsh in the process and have used it as my shell rather than bash ever since.
- caiob 7y agoAny beta testers here able to confirm whether Terminal.app supports True Color now?
- opk 7y agoCan't answer that but on a related note, recent zsh fully supports true color. You could always use it in things like prompts with literal escape sequences but it'll also work for syntax highlighting etc and interpret colours in hex triplet form for you now.
- saagarjha 7y agoIt doesn't look like it.
- dandigangi 7y agoHad no idea they were shipping zsh in newer versions. Neat! Wonder why they don't do Bash 4.x.x+ versions by default. Or, do they?
- reilly3000 7y agozsh is the default shell on all of my machines because I make it so. I think the tab completions that ohmyzsh provides have saved me on the order of 40 hrs / year, and helped me learn new APIs much easier, since you can see all options without the --help. If you haven't tried it, I cannot recommend zsh + plugins enough. Only install that you actually use, otherwise it can slow start time a bunch. Here is a list of the plugins that are available: https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins I especially appreciate git+git-extras, web-search (`google my query`), docker, npm, and dirhistory.
- farisjarrah 7y agoShout out to the fish shell which can do all the fancy syntax highlighting and show command options out the box with no plugins
- okdana 7y agozsh doesn't require any 'plugins' for its tab-completion, everything you need is distributed with the shell. A lot of people who use zsh just don't understand how it works and think that OMZ/Prezto/whatever are doing something special for them that they couldn't achieve themselves with one line in their .zshrc (or that may even be enabled by default in their OS's global zshrc, as is the case on Ubuntu for example)
- TehCorwiz 7y agoYeah, I went that route before settling into Oh-My-Zsh. The thing is, those single lines add up quick leading to increased mental overhead and time investment. It's never been about 'understanding' zsh or not, it's always been about making it comfortable to use, quickly, on any given system I might use. Sometimes a nice set of defaults is more productive than a custom solution.
- okdana 7y agoI agree that zsh's default configuration sucks (and the new-user wizard is overwhelming). I would like the project to provide a more opinionated set of defaults to OS vendors; i think we are probably just nervous about breaking 30 years' worth of expectations, and so far nobody has really pushed for it. But i do think the misunderstanding i mentioned is very common, as illustrated by the fact that the GP seems to think that OMZ itself provides zsh's completion functionality. It's also a frequent point of confusion with people seeking assistance on zsh's IRC channel.
- fouc 7y agoI've noticed that sometimes there's oddities with zsh & homebrew or rvm that force me to drop into bash in order to run a command. With apple standardizing on zsh, that should finally resolve these bugs.
- samgranieri 7y agoFantastic! Any time I get a new mac I install homebrew ZSH and edit /etc/shells to add it in.
- mikl 7y agomacOS already ships with zsh, and has done so for years, it’s just not the default shell. Unless you want to always have the very latest version of zsh, you don’t need to install it with homebrew.
- drejay 7y agoFor all forms of hacking services, talk to darkcracker@protonmail.com
- duskwuff 7y agoOoh, and they're throwing in dash too! > To test script compatibility with Bourne-compatible shells in macOS Catalina, you can change /var/select/sh to /bin/bash, /bin/dash, or /bin/zsh. If you change /var/select/sh to a shell other than bash, be aware that scripts that make use of bashisms may not work properly.
- geuis 7y agoI’m only familiar with working in bash and bash scripts. What do I need to know about the differences with zsh?
- dontbenebby 7y agoI've never worked outside bash. I have a lot of simple bash scripts. (Usually just stringing together commands with the occasional pipe or output to file) Will this break all those or are bash scripts and zsh scripts basically interchangeable?
- franky47 7y agoIf they start with a shebang like `#!/usr/bin/env bash` indicating which shell they are written in, it should be fine.
- dmix 7y agoAs all shell scripts should be.
- dontbenebby 7y agoCool. I have a couple that I forgot to because they're extremely minor (basically just a 4 line set of commands into one) but I can append that easily. Maybe I'll write a bash script to prep my poorly written bash scripts :D
- okdana 7y agoAs the other person said, if your scripts are executables with an sh or bash 'shebang' at the top, they will continue to use the same shell they always did. But if you did want to run them with zsh, most simple scripts that just set environment variables, string together commands, or redirect to files should work without any changes. The most obvious difference for basic scripts like that is that zsh doesn't split parameter-expansions on white space by default (so if you did something like `opts='-a -b -c'; mycmd $opts` it wouldn't work without additional, minor, modifications)
- romka2 7y agoThe minor modification would be from `$opts` to `$=opts`. I'd been using ZSH for a year as if it was Bash with better history and much better completions. The difference mentioned above was the only one I knew about. I kept writing my scripts in Bash and was quite happy with the UX.
- mmastrac 7y agoFrom 2012 - Apple's great GPL purge: https://news.ycombinator.com/item?id=3559990 https://news.ycombinator.com/item?id=3559990 Short-sighted move considering Microsoft is actively looking to ship a Linux kernel in Windows.
- paxys 7y agoAs a happy zsh user, I'm glad that this will finally force every application and software package in the world to stop assuming that bash is the default (and only) shell.
- tannhaeuser 7y agoWhile Apple is at modernizing their POSIX userland, they should also consider other ancient software they're using. For example, last I looked on Apple's Darwin Open Source site (about a year or two ago), they shipped a really old and buggy awk (nawk) version.
- jamil7 7y agoCan we get a modern python version while we're at it?
- spatulon 7y agoThey're just going to remove it completely: > Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. In future versions of macOS, scripting language runtimes won’t be available by default, and may require you to install an additional package. https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_release_notes?language=objc https://developer.apple.com/documentation/xcode_release_note...
- mondi 7y ago> Use of Python 2.7 isn’t recommended. This version is included in macOS for compatibility with legacy software. Future versions of macOS won’t include Python 2.7. Instead, it’s recommended that you run python3 in Terminal. (51097165) and > LLDB’s Python scripting is now based on Python 3. If you are using Python extensions that aren’t compatible with Python 3, they will break. To help with the transition, you can run in Python 2 mode by setting a default So looks like python 3 will become available and default
- wyclif 7y agoThe open secret to using Python on macOS is to leave the system Python (2.7x) completely alone and install pyenv/pipenv to manage your environments. This will save you a world of pain. Since it's 2019 and I no longer need 2.7, when I run this... $ pyenv versions system * 3.7.3 (set by /Users/wyclif/.pyenv/version) ...it's dead simple. Now, if I wanted to I could manage any number of previous versions with pyenv and pipenv.
- stunt 7y agoI use Fish. So not an exciting news for me.
- AnthonBerg 7y agoI use Fish too :) And I haven't really connected with zsh. I've tried. However I think this is good news for Fish too. It's the beginning of a long-overdue un-Bashifying.
- pierreprinetti 7y agooh crap. Yet another outdated package bolted into the OS.
- jhanschoo 7y agoI had trouble updating iTunes once because my shell was set to zsh, and it took me quite a while to debug what went wrong. I recommend that when this switchover occurs, users should temporarily switch to bash if they encounter an installer that does not work.
- bojanz 7y agozsh users, good time to try out my favorite prompt, Pure: https://github.com/sindresorhus/pure https://github.com/sindresorhus/pure Nowadays that's the only thing I run on top of zsh, which makes the shell significantly faster than with oh-my-zsh (and its kitchen sink).
- eeeeeeeeeeeee 7y agoI switched to ZSH a few years ago because some of my coworkers were using it. I never found it useful enough to use it over Bash. So I switched back to Bash. I’d rather have the shell be identical to the one running on the servers I use.