I have been a zsh user for quite some time (before that tcsh and before that csh). I am quite happy with it, but was wondering if there are any compelling features of bash that do not exist in zsh. And conversely, are there zsh features which do not exist in bash. My current feel is that bash is better:
- If you are familiar with it already and don't want to learn new syntax.
- It is going to exist on most all *nix machines by default, whereas zsh may be an extra install.
Not trying to start a religious battle here, which is why I'm just looking for features which exist in only one of the shells.
zsh is for vulcans. ;-)
Seriously: bash 4.0 has some features previously only found in zsh, like ** globbing:
is equivalent to:
but obviously more powerful.
In my experience bash's programmable completion performs a bit better than zsh's, at least for some cases (completing debian packages for aptitude for example).
bash has
Alt + .
to insert!$
zsh has expansion of all variables, so you can use e.g.
for this. zsh can also expand a command in backtics, so
yields
I find it very useful to expand
rm *
, as you can see what would be removed and can maybe remove one or two files from the commmand to prevent them from being deleted.Also nice: using the output from commands for other commands that do not read from stdin but expect a filename:
From what I read bash-completion also supports completing remote filenames over ssh if you use ssh-agent, which used to be a good reason to switch to zsh.
Aliases in zsh can be defined to work on the whole line instead of just at the beginning:
I would like to point out that bash is not installed by default on FreeBSD, OpenBSD, or NetBSD, and it is also not installed by default on Solaris 10 (OpenSolaris has it as the default), last time I used an AIX, and or HP-UX servers it was not installed by default either.
Also, on OpenSolaris /bin/sh is NOT bash. It is ksh. The biggest issues I have as a software porter is people that assume /bin/sh is bash and that it will accept bash extended syntax. While this seems to be the case on most Linux distributions it is not the case elsewhere and it is really annoying.
Although I am a bash user, I find one of zsh's features pretty cool: RPS1.
Remember:
Sample:
When using something like
You get your prompt on the left and the current directory pushed onto the right. It even disappears when the current line is getting too long ! It's because zsh is smart enough to give low priority to RPS1.
You can see a screenshot of this example at http://imgur.com/OAZhC.
Zsh has spelling correction. If you're a letter (or more) off, it will figure out what you meant.
It also has more robust tab completion, which I like.
Zsh has an interactive config utility to get it set how you like.
Some speed tests say zsh is faster, but I haven't noticed any difference.
I don't know of any bash features that zsh does not support. The design goal of zsh seems to include supporting any features that bash adds.
I still use bash instead of zsh. I rarely come across compelling features that zsh supports that bash does not. Occasional problems with zsh over the years, or it not existing on certain sysetms, have made it not worth making the transition.
I can finally use the same shell on every Unix system, it's not worth breaking this for features I'll never use.
The features present in zsh that are not present in bash seem to mostly be cute but not ones that would matter on a day-to-day basis.
bash has many features that used to only be in zsh. You can have 'smart tab completion' with bash aswell now, as any recent ubuntu user has discovered.
Process substitution and extended globbing are the two features I would miss the most. The prompt settings are pretty cool too - seeing the level of nesting when you are typing complex statements on the command lines. Autoloading makes including lots of functions in every shell feasable.
I'm a fan of zsh because of the vi mode support, but I am discovering that it's not very widely used. I think I read that zsh likes to take popular features from the other shells and combine them (so things specific to bash and thing specific to csh are both available in zsh).
Someone also said that I'm flexing my geek factor by using zsh, but I can't confirm or deny that rumor.
Popularity, #bash 430 users. #zsh 123 users. I believe the zsh website has a good comparison of zsh with other shells. zsh has better vi mode support.
Bash is using the same syntax for if and while as that can be used in /bin/sh scripts on the command line.
Within zsh the syntax is different. Effectively using zsh you have to remember both, if you are using an if- or while-statement on your command line