Updated September 18, 2023
Difference Between Zsh and Bash
- Zsh is called Z Shell, which is an extension of Bash that has many new features and themes. Zsh was released in 1990 by Paul Falstad. Zsh has similarities with Korn shell as well. Linux and Mac OS use Bash as their default shell.
- Bash is the abbreviation of the Bourne-again shell. In 1971, the UNIX operating system was released along with the Thompson shell. In 1979, the Thompson shell was modified and released as a Bourne shell. Brian Fox released Bash in 1989 for his project that provided improvements from its previous versions. Bash release enhanced its use as a scripting language. The default Zsh is different from Bash.
Head to Head Comparison Between Zsh and Bash (Infographics)
Below is the top 36 comparison between Zsh vs Bash:
Key Differences Between Zsh and Bash
Let us discuss some of the major key differences:
- Zsh is more interactive and customizable than Bash.
- Zsh has floating-point support that Bash does not possess.
- Hash data structures are supported in Zsh that are not present in Bash.
- The invocation features in Bash is better when comparing with Zsh.
- The prompt look can be controlled in Bash, whereas Zsh is customizable.
- The configuration files are .bashrc in non-login interactive shells and .profile or .bash_profile in login shells of Bash. In Zsh, non-login shells are .zshrc and login shells are .zprofile.
- Zsh arrays are indexed from 1 to length, whereas Bash is indexed from -1 to length.
- In Zsh, if the wildcard patterns do not match any file, it throws an error. While in Bash, it is left unchanged.
- The right-hand side of a pipeline is run as a parent shell in Zsh, while in Bash, it is run as a subshell.
- In Zsh, zmv function is used for mass renaming, while in Bash, we have to use the parameter expansion feature.
- Bash has good scripting capabilities in a single line, while in Zsh, we could not find the same.
- The output is stored in a temporary file by default in Zsh, while in Bash, it is not.
- Many built-in features in Bash make complex programs easy, while in Zsh, built-in features for complex programs are less.
- Zsh manages its files effectively, while Bash is not good at operating its files.
Comparison Table of Zsh vs Bash
The table below summarizes the comparisons:
Sr no. | Zsh | Bash |
1 |
Users are less when compared with Bash | Users are more and hence community support as well. |
2 |
Auto completion is faster. | Auto completion is not faster as Zsh. |
3 |
Zsh has inline wildcard expansion. | Bash does not have inline wildcard expansion. |
4 |
Tab completion is like a drop-down menu in Zsh. | Tab completion is like a command output in Bash. |
5 |
Zsh has prefix and suffix command aliases. | Bash does not have prefix and suffix command aliases. |
6 |
Zsh follows the POSIX standard more closely. | Bash does not follow the POSIX standard as much as Zsh. |
7 |
Zsh functionality is more configurable. | Bash functionality is not much configurable. |
8 |
The tab is used to navigate between options. | No such option is available in Bash. |
9 |
Zsh has many themes and plugins. | The bash option for themes and plugins is less. |
10 |
A directory name change can be done easily in Zsh. | The directory name cannot be automatically changed in Bash. |
11 |
Zsh will fix the spelling and completion of words. | Bash will not fix anything by itself. |
12 |
While taking the value of a variable, Zsh has many ways to apply the transformation. | Bash has very few ways to apply the transformation to the variable. |
13 |
Glob qualifiers in Zsh show matching files that are based on metadata. | Bash does not have any Glob qualifiers. |
14 |
Extra wildcard patterns are enabled automatically in Zsh. | In Bash, extra wildcard patterns are enabled with the help of shopt -s extglob. |
15 |
# is not treated as a comment by default in Zsh. | In Bash, # is considered a comment by default. |
16 |
Zsh has setopt settings. | Bash has shopt settings. |
17 |
Zsh completes command and file names by running compinit. | Bash completes command and file names by running bash_completion. |
18 |
Zsh is more precise, and if something is wrong, it shows an error. | Bash does things by itself, which may not be right but sensible. |
19 |
Zsh prompt contains percent escapes. | Bash prompt has backslash escapes. |
20 |
Using Zsh, we can build fancy prompts. | In Bash, we are not able to build fancy prompts. |
21 |
Binding keys in Zsh is done by the bindkey. builtin. | Bash uses .inputrc and the bind builtin to bind keys. |
22 |
User configuration settings are stored in .zshrc. | User configuration settings are stored in .bashrc. |
23 |
Zsh has the Oh-my-Zsh community to help in scripting. | Bash has no defined community as such, but since it is old, there are many online communities to support in scripting. |
24 |
Zsh can display a split screen similar to vim’s split-screen. | No such option is available in Bash. |
25 |
Calculations can be done in Zsh using zcalc command. | Expr and bc external calculator are used in Bash to do calculations. |
26 |
In Zsh, zparseopts command is used to parse the script. | Getopts built-in command is used in Bash to parse scripts. |
27 |
Expanded aliases are allowed anywhere in a line if the alias is used in the command. | Bash does not allow this feature in the line. |
28 |
Environment scripts of Zsh are zlogin, zlogout, zprofile, zshenv, zshrc. | Bash does not have many environment scripts. |
29 |
While doing the startup, shellopts is not run. | Shellopts is run automatically while starting up the Bash. |
30 |
Scripting is not that good as compared with Bash. | Bash has good scripting capabilities. |
31 |
History is shared in all instances in Zsh | History sharing is not that easy in Bash. |
32 |
Zsh is not similar to Emacs at all. | The shortcuts in Bash are very similar to Emacs. |
33 |
Customization is done during the installation process in Zsh. | Customization is done by checking the configuration settings in Bash. |
34 |
Configuration files are not easy to explore. | Configuration files are made easy in Bash. |
35 |
Zsh has many advanced features. | Features are not advanced. |
36 |
Auto-completion is a feature of Zsh. | Third-party plugins have to be installed for auto-completion. |
Conclusion
Interactive configuration features have many differences while comparing Zsh and Bash. Zsh is known for its extensibility, good customization, and advanced features. Since Zsh is made from Bash, almost 90% of the scripting is similar, and it is compatible with Bash. Both Zsh and Bash have many similarities and are easily portable. Many systems started using Zsh as their default shell.
Recommended Articles
This is a guide to Zsh vs Bash. Here we also discuss the Zsh vs Bash key differences with head to head comparison (infographics) and comparison table. You may also have a look at the following articles to learn more-