5 ms·
For the uninitiated: why is zsh better than bash?
by youeseh 7y ago
For 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 .
- PascLeRasc 7y agoTab 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.
- cferr 7y agoYou 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.
- kbd 7y agoA 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.
- nullbyte 7y agoIt has a ton of great features, but my favorite is definitely the improved tab completion.
- myhf 7y agoIt runs slower, so it helps encourage you to buy more expensive hardware.
- zbentley 7y agoIf 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.
- jamienicol 7y agoGit 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.
- m45t3r 7y agoCheck 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.
- jamienicol 7y agoI'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.
- 7y ago