Re:Use zsh as the default shell on your Mac
by youeseh on Monday June 03, 2019 @08:03PM
(#20090373)
For the uninitiated: why is zsh better than bash?
[ Parent
| on HN ]
The 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).
Re:Use zsh as the default shell on your Mac
by bsimpson on Monday June 03, 2019 @08:36PM
(#20090609)
For even more historical context, macOS originally shipped with tcsh. We've already done the shell transition once, and basically nobody noticed.
Re:Use zsh as the default shell on your Mac
by koenigdavidmj on Monday June 03, 2019 @11:00PM
(#20091365)
That 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.
Is that what they've done? The linked article doesn't say that.
$ /bin/sh --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.
Re:Use zsh as the default shell on your Mac
by koenigdavidmj on Tuesday June 04, 2019 @09:42AM
(#20094912)
You can change this by pointing /var/select/sh .
A couple of the things that make it much better for me are plugins: zsh-autosuggestions and zsh-syntax-highlighting. I think those are both fish-inspired, but getting those features in a bash/posix-compatible shell is the best of both worlds.
Re:Use zsh as the default shell on your Mac
by PascLeRasc on Monday June 03, 2019 @08:14PM
(#20090455)
Tab autocompletion, especially for command-line flags, is great. Try it out with 'ls -<TAB>' and you'll see all the options and a description. The z command to cd to common directories without typing the full path seems useful, but I've never gotten it to work.
You can setup command-line flag completion in bash as well. For example, on my Linux systems I have this line in my .bashrc to autocomplete systemd unit file names for when I run systemctl:
complete -W "$(systemctl list-unit-files|cut -f1 -d' '|tail -n+2|head -n-2)" systemctl
Bash also allows you to cd to common directories, but again, you have to set it up. You set the CDPATH variable to one or more paths, and then you can cd to relative subdirectories without typing out the absolute path.
Re:Use zsh as the default shell on your Mac
by nullbyte on Monday June 03, 2019 @08:50PM
(#20090683)
It has a ton of great features, but my favorite is definitely the improved tab completion.
It runs slower, so it helps encourage you to buy more expensive hardware.
Re:Use zsh as the default shell on your Mac
by zbentley on Monday June 03, 2019 @11:32PM
(#20091592)
If your hardware cost is driven by the performance of your shell, I question what you're doing with your terminal emulator.
I can think of essentially zero areas in which zsh is slower than bash in which it is slow enough to create the need for a hardware upgrade, or even contribute to such a need on an already-overloaded system. I mean, sure, file performance bugs if you want.
But your shell is not going to be the "oh christ, this is slow" program; it doesn't run Electron for chrissakes.
Re:Use zsh as the default shell on your Mac
by jamienicol on Tuesday June 04, 2019 @05:18AM
(#20093312)
Git completion is unbearably slow for me in zsh, but fine in bash. It is a very large repo I work on, but we're talking 10s vs instant. I still use zsh though because it's nicer in other ways.
Check your Zsh theme. Zsh has no built-in support for git status, so themes that show git status are implementing this by themselves. One way to make this slow is to check git status synchronous, however there are ways to do this asynchronous that should be instantaneous (at the expense of showing git status later).
Btw, Bash is the same. So you just said that someone that implemented your Bash theme did better than in your Zsh theme.
Re:Use zsh as the default shell on your Mac
by jamienicol on Wednesday June 05, 2019 @06:01PM
(#20109614)
I'm taking about tab completion when entering commands, not a theme that is displaying my status anywhere. I didn't even know "themes" existed.
Your point probably stands that it's more to do with the completion scripts rather than the shells themselves though.
Re:Use zsh as the default shell on your Mac
by zbentley on Thursday June 06, 2019 @09:32AM
(#20114332)
There are absolutely some things slower in zsh/bash. Are any of those slow because of a non-upgraded machine ("they would run fast on a $50k server" doesn't count)? Or, as others in this thread have pointed out, are they slower because of flawed implementations which, unless fixed, will always be slow on any hardware?