Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unrelated but I'm wondering. Should I switch from bash to zsh, if so, why? It's taken me quite a while to get up to speed with bash, especially scripting. How steep is the learning curve?


Zsh is a superset of Bash. There's little-to-no learning curve from switching, if you just stick with Bash syntax, and many advantages.

Here is a good overview on Zsh vs. Bash [0].

My favorite Zsh feature is the plugin ecosystem [3]. Oh My Zsh [1] and Starship [2] are awesome.

[0]: https://apple.stackexchange.com/questions/361870/what-are-th...

[1]: https://ohmyz.sh/

[2]: https://starship.rs/

[3]: https://github.com/unixorn/awesome-zsh-plugins


> Zsh is a superset of Bash.

zsh is not a strict superset of bash; I have aliases that I still haven't figured out how to port


I had a script that worked fine in BASH but errored in Zsh. It had to do with arrays and I don't remember the problem.


It was probably that in zsh, arrays start at 1.


I'll take this chance to shill for Fish. For interactive use it is a joy to use, with better defaults w.r.t. auto completion and history. Not much learning curve if most of the time you're just entering commands and pressing tab or arrow keys. I still use Posix Shell for scripts though, because it's installed everywhere.


I'm going to go against the grain a little and disagree with a lot of the comments.

My suggestion is to use the same environment in development that you use in production. If you are running zsh on your servers then run zsh on your workstation.

I run a mix of Linux, FreeBSD, and OpenBSD servers in production; and have found that 99% of the time it didn't matter.

I had been using zsh on my workstation and about 25% of my server fleet. The others were either too old, didn't support it, or whatever.

Of those 75% of servers (over 500 boxes) a small handful encountered occasional problems when running my 'written on ZSH script'; that didn't happen when I re-wrote/tested the script on bash.

We are talking about ~4 errors over the course of a year-and-a-half or so.

It was more annoying then anything else; and nothing broke as a result of it. I just had to manually go do the work that my script was suppose to do.

I like zsh.


Most bash scripts work fine in zsh. I recommend you switch because your learning curve will be very shallow.

Here's a gist (i.e. no ads) that I wrote to guide people new to zsh through some of the many options available: https://gist.github.com/aclarknexient/0ffcb98aa262c585c49d4b...

Here's a stack exchange post about the differences between zsh and bash: https://apple.stackexchange.com/questions/361870/what-are-th...


Definitely switch to zsh for interactive use, the differences are minimal enough it will not take any effort to switch. Even forgetting everything else just the superior tab complete is enough to make it worthwhile. Still use bash for scripts they will be more portable.


macOS ships with zsh and it was easier to switch all the linux boxes to zsh than to fight homebrew into giving me a relatively recent version of bash.

So far I've no complaints and oh-my-zsh is nice.

But I can't really point to something and say "oh I'd die without this zsh feature".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: