What is the advantage of using zsh versus the omnipresent bash ? I mean there is something that can be done only in zsh and not in bash; or something that is straightforward to do in zsh and cumbersome in bash ?
Of course I can learn zsh to increase my knowledge, but it will be nice to see some clear advantage of using zsh.
I'm really glad I switched from bash to zsh a few years ago. zsh is, IMHO, a tiny bit better than bash in many areas. Because I use it all day every day, these little bits better add up to a lot of benefit.
Even if the answer is "none", zsh will need to additionally defend "what is the advantage of zsh for someone who already knows how to use bash", as any form of switch is going to come with a cost. I would therefore be really interested in your reasons (I use bash, as currently do all of the people I know and work with; [edit: apparently except one]).
It seems like most of the features listed as better than bash are either a) covered by bash 4.0, b) bad ideas (shared history among sessions), or c) only controversially better (searching around, people seem to argue back/forth about which programmable completion implementation is faster/better).
Same, i'm rather new to using zsh but it would help greatly if there was a comparative list between bash and zsh defining the differences. It was suggested to me by a couple of friends but at this stage, i'm not clear on why I would benefit from using zsh over bash.
Zsh is quite a bit nicer than Bash for scripting. For one, parameter expansion doesn't word-split by default, so you don't have to haphazardly quote everything. There's also some really powerful features, like the parameter expansion flags [1] and filename generation (globbing) flags [2] that can be combined to do very flexible things. [3]
Zsh also bundles a ton of useful modules that can be used to do things pretty outside the box. Eg, there's a module for creating and controlling a hidden PTY. [4]
Zsh also has some quite nice shorthands for basic grammar, like compact loops and conditionals. Eg, you can do:
for foo in bar*;
do_stuff # you don't need the do..done here for single-line for-loops
Also, while Zsh diverges from POSIX sh in some areas (like word splitting), Zsh has sh- and Bash-compatible emulation modes, which can even be mixed together within single scripts (eg functions can set their emulation mode and shell options locally, or files can be sourced or commands run with different emulation modes prefixed). [5]
Lastly, Zsh has this weird reputation for being slow, because the configuration frameworks like oh-my-zsh are absolute dogs. But it's actually among the faster shells, with very respectable script performance that's squarely ahead of Bash. [6] Interactive performance can also be fantastic if you use a less hungry framework or write your own config, and Zsh has many tools to improve speed further, like support for pre-compiling source files [7] and pretty good support for async workers. [8]
Zsh has also been around about as long as Bash, and runs on every major platform and is available in just about every platform's package manager. So the cliche about Bash being available everywhere is just as true for Zsh. Zsh is honestly a much better replacement for scripting, but Bash benefits from already established traction and by being the default shell on most Linux distros.
I preferred Zsh for a long time because it was much nicer to program in than Bash. But Bash has since then picked up all of the Zsh features I cared about and is installed by default most of the time so I switched.
For me the really compelling reason to use zsh is that it's "like bash, but without the gotchas." For example, $* just works, even if the args have spaces. You don't have to think about "$@" which still doesn't work sometimes.
I used to use zsh way back in the day because it was clearly superior to bash, then decades ago switched to bash because it was everywhere by default and my job involved using lots of computers that only had bash on them, then about 4 or 5 years ago I switched back to zsh because I realized that it really didn't matter that I used zsh on my own machine and bash on others, and zsh was still better than bash.
These days bash seems to have a lot closer feature parity to zsh, and I'd be curious to read an up-to-date comparison of both shells to determine if either is clearly better than the other.
I also still script in bash, as zsh sometimes has some minor deviations that are not directly that obvious.
One of the reasons I use zsh is because of all the plugins that exist for it. With them I have the feeling that they boost my productivity. But the real reason is, zsh feels more like it does what I want/expect compared to bash (, that is probably subjective?).
* zsh has a ton of interactive chrome built-in, and a lot of it is on by default.
This leads to some incompatibility with bash for scripting purposes
the contextual completion stuff is infuriating when it's overly restrictive
* A pure bourne shell (like dash) by nature doesn't support bashisms
like $() as an alternative to ``
On almost all gnu systems /bin/sh is a link to bash
which checks $0 and operates in sh mode
Unfortunately bash's sh mode is completely broken
it allows most bash-specific syntax
so almost a lot of Linux users's #!/bin/sh scripts really need bash
The takeaway is that you should give up and use bash, or write your own shell if you're an asshole (I have done this).
zsh has better completion, command line editing capabilities, and language features. It's not even close. I can port my bash configuration to zsh in mere minutes, but it's impossible to port my zsh configuration to bash. The reason is simple. Bash just lacks so many features.
> For example, it is common to see command line tool come with bash completion files, less so with zsh.
It's rare for bash to complete anything but filenames. zsh gives me subcommands and flags with descriptions.
> Also, while bash got better support where it matters, zsh mostly got bloat in the form of oh-my-zsh and the likes.
zsh is a well-maintained project. It makes no sense to ignore that and instead fault them for oh-my-zsh's shortcomings, as if it has anything to do with upstream zsh. zsh doesn't rely on oh-my-zsh for any of its features.
zsh 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?
I don't use zsh because I don't spend a lot of my time at the shell or do anything complex with it when I am using it. Most of my time is spent in a text editor, and for the little amount of time I spend doing things on the shell, bash (or really, whatever the heck the default shell is) has worked fine for the basic tasks I need it for. I suppose it's possible that I'd like zsh more than bash even for what I'm doing now, but honestly, I don't even think about bash. It's just there, and it works enough of the time that I don't even have any complaints about it.
Of course I can learn zsh to increase my knowledge, but it will be nice to see some clear advantage of using zsh.
reply