The Difference Between Bash and Zsh

Bash (Bourne Again SHell) is the default shell in most Linux distributions, while Zsh (Z shell) is a powerful alternative shell with many additional features.

Some of the main differences between Bash and Zsh are:

Configuration Files

Bash reads:

  • .bashrc for non-login interactive shells

  • .profile or .bash_profile for login shells

Zsh reads:

  • .zshrc for all interactive shells

  • .zprofile for login shells

This means if you switch from Bash to Zsh, you'll need to port your Bash customizations over to the Zsh configuration files.

Key Bindings

Bash uses .inputrc and the bind builtin to bind keys to readline commands.

Zsh uses the bindkey builtin to bind keys to zle widgets.

This means your Bash key bindings will not work in Zsh, and vice versa. You'll need to reconfigure them.

Prompt

Bash uses backslash escapes in $PS1 for the prompt.

Zsh uses percent escapes in $PS1.

This means Bash prompt customizations will not work in Zsh. You'll need to port them over using the Zsh syntax.

Features

Zsh has many additional features compared to Bash:

  • Glob qualifiers

  • zmv for mass file renaming

  • History modifiers

  • vared to edit variables interactively

  • Built-in spell-checking

  • Plugin and theme support

Compatibility

While Zsh syntax is not 100% compatible with Bash, most common Bash code will work in Zsh. The main incompatibilities are in interactive configuration.

Scripts using a shebang line like #!/bin/bash will continue to work as Bash is still installed.

In summary, while Bash is the default shell on Linux, Zsh offers many additional features and customization options. If you switch from Bash to Zsh, you'll need to port your Bash customizations over and reconfigure things like key bindings and prompts. But simple Bash scripts and commands will generally continue to work.

Hope this helps explain the main differences between Bash and Zsh! Let me know if you have any other questions.